Is it possible that onPause() is called, and then immediately after that, onResume() is called? In other words, does the activity always has to go through onStop(), onStart() and then onResume() after its onPause() is called?
The activity lifecycle document says it is possible, but what would be the user actions to trigger that? Can anyone create an activity JUnit test to demonstrate that?
Yes, it is common for
onPause()->onResume()->onPause()->onResume()cycle to occur.See the Activity lifecycle docs.
If an
Activityis totally obscured (by anotherActivityfor example) it will likely be stopped but if it is only partly obscured by anotherActivity(set with a dialog theme, for example), then it will simply be paused and then resumed when the ‘popup’Activityis closed.