Perform action if app is not used for specified time in android
<p>I have an android app in development which enables the user to protect the data inside the app by entering a password or pin. Is there a method to check if the app hasn't been used for lets say 10 minutes to then change a setting in the app prefs file. </p>

<p>I was thinking of maybe a service, or a class within the app that runs instead another thread with a timer but not sure if this would be suitable. </p>

<p>Another method, I was thinking is there a way so that when the user presses the home button, the home button does its normal task of return to the android home screen but it also changes a setting within the apps prefs file. </p>

<p>Thanks for any help you can provide. </p>
