title: Detect application coming from the background and prompt for PIN in Android
body: <p>I have an app in which I need to prompt the user to enter the PIN every time the app comes from the background.</p>
  
  <p>I looked several answers from stackoverflow from @hackbod and @commonsware
  I implemented the timeout approach from @commonsware and it worked fine, but my users are not happy with it. They want to prompt for PIN everytime when the app is coming from background.</p>
  
  <p>Now I am implemeting the solution from @hackbod by having every activity increment the counter in onStart and decrement the count in onStop. 
  <a href="https://stackoverflow.com/questions/5836843/android-detecting-if-an-application-entered-the-background">Android detecting if an application entered the background</a></p>
  
  <p>But the problem is when users changes the Orientation of the current activity the counter sets back to 0 and my app thinks the user is coming from background. 
  my onStart() increments the counter and onStop is decrementing the counter.
  I want android to take care of the orientation change as I have different layouts for different orientation.</p>
  
  <p>I don't want to use GET_TASKS approach for now. 
  All suggestions are appreciated..</p>