Issue
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.
I think it has something to do with the application lifecycle, maybe a static variable. But I don't know where to start.
Has anyone got a solution or a tip so I can finish this thing?? Would be greatly appreciated
Solution
Use Shared Preference in this case Note the current time when the app closes and on Restarting the app compare the current time with the stoppage time and then find the difference in time. If it is greater than your demand then Request Login Page. If you want sample code for difference of time I can edit my Post
Answered By - Arslan Ali
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.