Results of some experiments to determine which Activity lifecycle methods get called in certain situations.
Launch:
- activity.onCreate()
- activity.onStart()
- activity.onResume()
- activity.onWindowFocusChanged(true)
Note: Launching already-running app is similar, except a call to activity.onRestart() will occur instead of onCreate().
Press Home:
- activity.onUserInteraction()
- activity.onUserLeaveHint()
- activity.onPause()
- activity.onWindowFocusChanged(false)
- activity.onSaveInstanceState()
- activity.onStop(); isChangingConfigurations() returns false
(activity1 is the activity that was on the top of the stack. activity2 is the new activity being pushed on top.)
- activity1.onPause()
- activity2.onCreate()
- activity2.onStart()
- activity2.onResume()
- activity1.onWindowFocusChanged(false)
- activity2.onWindowFocusChanged(true)
- activity1.onSaveInstanceState()
- activity1.onStop(); isChangingConfigurations() returns false
If activity1 calls finish(), then activity1.onDestroy() will occur after onStop()
(activity2 is the top-of-stack activity being dismissed. activity1 is the activity that is beneath activity2.)
- activity2.onUserInteraction()
- activity2.onPause()
- activity1.onRestart()
- activity1.onStart()
- activity1.onResume()
- activity1.onWindowFocusChanged(true)
- activity2.onWindowFocusChanged(false)
- activity2.onStop()
- activity2.onDestroy()
- activity.onConfigurationChanged()
- activity.onPause()
- activity.onSaveInstanceState()
- activity.onStop(); isChangingConfigurations() returns true
- activity.onDestroy()
- activity.onCreate()
- activity.onStart()
- activity.onRestoreInstanceState()
- activity.onResume()
- activity.onWindowFocusChanged(true)