I was wondering what would be the best way to handle an application timeout, such as PayPal. I want the user to select between 1, 5, or 15 minute timeout period, so when they open up the application they would have to log in again.
My onResume method:
@Override
public void onResume() {
}
It has nothing in it. But it crashes.
As a note: my app has two activities. The first activity is a login screen. The second activity is the main screen. The onResume method is in the second activity.
I did this in one of my apps:
You need a base Activity for which all of your activities will extend from. In this base activity, add a variable that keeps track of the ‘last user activity’ timestamp. In my case, user activity simply means they touch the screen. So override the dispatchTouchEvent(MotionEvent ev) method, and set the ‘last user activity’ to current timestamp.
Then in onResume() method of this base activity, just compare current timestamp with ‘last user activity’ timestamp. If it more than either 1, 5 or 15 minutes (configurable by user), then launch another activity to ask the user to login.