I have an application where you have to log in like an user with your password.
This application needs to be secure, so it needs to Log Out the user when he doesn´t tocuh the screen during a determinate period of time(let´s say, 5 minutes).
The problem is that, once the user is logged in, he can go through many activities, not only one, and I would like to know if there is a way in Android to know if the user can get Logged out after few minutes.
I was thinking about using the method onInterceptTouchEvent(MotionEvent ev), but the problem is that, ¿do I have to use this method on every activities? ¿there is another easier way to manage it in Android?
Thanks a lot!
Instead of implementing this on every
Activity, you could create oneActivitylike this:and implement
onInterceptTouchEventin yourBaseActivity.Then from all other
Activitiesyou will have to extend theBaseActivityUPDATE:
You will have to use
onTouchif you want to listen for events in whole screen. This requires that in every xml file of yourActivity, you will have to give anidfor the root view of your xml (Linearlayout,Relativelayout,Framelayoutor whatever). So in order to let yourBaseActivityget inputs from otherActivitiesyou will have to pass your root view to it, like this: