I have an application where the user can log in. The login needs to persist. What I do now is test in onPause whether the activity isFinishing(). If not, that must mean the user is leaving the app (or screen is dimmed, or phone call, or whatever). Now I want to log the user out if he doesn’t come back within 15 minutes. Is it okay to do a postDelayed(…, 15*60)? Will this get executed in the background? Can I do a network call there to log the user out and how sure am I this actually gets done? In case the app is going to get killed within those 15 minutes, is there a hook where I log the user out?
Share
I think it’s possible to combine the AlarmManager with a broadcast receiver that captures the Intent generated by it.
This link might be useful:
http://www.dotkam.com/2011/01/10/android-prefer-alarms-and-intent-receivers-to-services/