I need to start the log in Activity
if the user wasn't active for 5 minutes in the application
,without considering from what activity he left the application. (by not active for 5 minutes I mean that the user didn't commit any action to the server side)
I have a Date
variable inside my Application
class:
private Date timeOfLogin;
that's is saved when the user commits log in, in some point of usage the user can get a phone call or a mail and will leave the application. now this can happen on any screen of the application. And now when he turns on the application again /return to it after finishing his phone call I need to show the log in screen again and not his last activity if 5 or more minutes have passed.
How can it be done? do I have to override every onResume
of each activity I have in the application and start the log in Activity
if the difference between the timeOfLogin
and current date is bigger then 5 minutes? or is there a better way to do that?
Any help would be appreciated.
Thanks.
Have an activity that all of your other activities extend and put the logic in that activity's onResume. (You'll probably find this practice to be useful in a lot of other ways too)
Create a
CountDownTimer
with 5 minute count down in your ResponseHandler class in theonFinish()
show thelogin
dialog. If there is any response cancel the timer and start again.