Skip to content
Commitwise
Menu

What's the difference between a configuration change and process death on Android, and what survives each?

AndroidMid-level

In shortA configuration change (rotation, dark mode) destroys and recreates the Activity while the process lives on, so the ViewModel survives. Process death kills the whole app in the background; only saved instance state (SavedStateHandle, rememberSaveable, the navigation back stack) and persisted data come back.

Model answer

Configuration change: rotation, dark mode, locale, font size or window size change. The Activity (and its composition) is destroyed and recreated in the same process. Fields and remember are lost; the ViewModel survives; rememberSaveable/onSaveInstanceState values are restored.

Process death: the app is in the background and Android kills the process to free memory, with no callback. When the user returns, Android recreates the last Activity and restores its saved instance state: SavedStateHandle, rememberSaveable, the navigation back stack. The ViewModel, singletons and caches are new and empty.

RotationProcess death
Fields, rememberLostLost
ViewModelKeptLost
SavedStateHandle, rememberSaveableKeptRestored
Database, DataStoreKeptKept

Design: keep data and in-flight work in the ViewModel, user input and ids in saved state, and important drafts on disk; reload data from saved ids. Test process death with adb shell am kill <package> while the app is in the background, or “Don’t keep activities”.

What they're looking for

What each event is, what survives each (fields, remember, ViewModel, saved state, disk), how to test process death, and how to design screens that rebuild from saved ids.

Common mistakes

  • Saying the ViewModel survives process death.
  • Testing only rotation.
  • Putting large data or secrets in the saved-state Bundle.

More android questions

Esc

Type to search the whole site.