title: How to detect user inactivity in Android
body: <p>User start my app and logs in.<br>
  Selects Session Timeout to be 5 mins.<br>
  Does some operations on the app. (all in foreground)<br>
  Now User bring Myapp to background and starts some other app.<br>
    ----> Count down timer starts and logs out user after 5 mins<br>
  OR user turns the screen OFF.<br>
    ----> Count down timer starts and logs out user after 5 mins</p>
  
  <p>I want the same behavior even when the app is in the foreground but user doesn't interact with the app for a long-time say 6-7 mins. Assume the screen is ON all the time. I want to detect kind of <strong>user inactivity</strong> (No interaction with app even though the app is in the foreground) and kick start my count down timer.</p>