General topic questions
Activity & process lifecycle
MediumMost asked
Free section · general topics & algorithms
Explain the Activity lifecycle and what happens when the process is killed in the background. How do you save state?
Reveal model answer
onCreate → onStart → onResume → onPause → onStop → onDestroy. Process death can wipe in-memory state after onStop. Persist UI state with onSaveInstanceState / SavedStateHandle, and durable data in DataStore/Room. Distinguish configuration change (recreate Activity) vs process death.