I have a main activity which is showing/hiding a bunch of fragments. There is a login activity at the very start that logs the user in. When the user presses home or the multi-tasking button, the app should start a timer that (after the timer runs out) automatically logs the user out. This could be when the user returns to the app (and timer has run out -> logout) or while in the app and has done nothing.
What exactly gets called when the user presses home/multi-tasking button in terms of the fragment's lifestyle methods? In my quick tests, it seems that the first fragment in the fragment manager's onPause is called everytime no matter the fragment on screen when the user exits out.
How can i go about this?
Please have a look at this tutorial about the Fragment-Lifecycle:
It explains the lifecycle of the Fragment with respect to its Activity.
When the user presses the home-button for example:
onPause() - fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.