How do I check if the app is closed/locked to logout the user

Hi guys, I need some help!

I'm pretty new to android and currently I ran into a problem concerning login and logout of a user. I have these activities:

  • Splash activity
  • Map activity
  • Transactions activity
  • Settings activity

The idea is that when a user goes to transactions a login is requested. After the user is logged in he stays login while he uses the app. Even if he stays on a page and does nothing for multiple minutes. When the app locks or closes the user is logged out after 60 seconds. When he comes back in time he stays logged in, otherwise a new login form is shown.

So I was thinking on how to solve this. My first thoughts were to set a timer when the app locks/is closed. When the user comes back the timer is checked. If after 60 seconds the user details (in memory) are thrown away.

The problem is I have trouble to solve this. I know of the activity states (onpauze, onresume, etc) but this is for an activity only so that won't work, I think. Maybe there is something with sessions I don't know about?

Has anyone got a solution or a tip so I can finish this thing?? Would be greatly appreciated :)

Sign In or Register to comment.