The Life and Death of an Android Activity
summary
A simple ticker app loses its count on rotation and when entering multi-window because Android treats those as runtime configuration changes and destroys then recreates the Activity, resetting the count from 0 even if it was 3; the fix is to persist transient UI with onsaveInstanceState (Bundle in onCreate). Backgrounded apps can also be killed by the Viking killer (process kill), so saved state still matters. Video pausing is solved by moving playback start/stop to onStart/onStop instead of onPause/onResume.
AI-written summary · about
chapters (17)
- 0:00Start
- 2:39The Android Activity Lifecycle
- 3:38Resource File
- 4:10The Activity Manager
- 4:33Activity Manager
- 5:33The Foreground Activity
- 5:48The Activity Lifecycle
- 6:55Stopped
- 8:35Build-Up Scenario
- 9:59Tearing Down the Activity
- 14:57Launching a Transparent Activity
- 17:10Visible Lifetime
- 17:30Foreground Lifetime
- 19:30Runtime Configuration Change
- 21:01Unsaved Instance State
- 26:25Multi Window Mode
- 31:27Life Cycle Pairs
related talks
38mActivities in the Wild: Exploring the Activity Lifecycle
30mSurviving a discontinuous world
45mFalsehoods Android Developers Believe About Lifecycles
24mWhere did my State go
28mAndroid Zombies: How to Not Get Bit
23mMaster of Lifecycle
40mNo Worries! Handling Don’t keep activities in the Compose era
39mFrustration-free orientation changes
