Member-only story
Stop Losing User Input in Jetpack Compose: Recover State After Android Process Death
Your ViewModel survived screen rotation. But will your student’s answers survive when Android kills the app process? Let’s build a safer solution using SavedStateHandle, StateFlow, and Jetpack Compose.
Imagine Losing 15 Minutes of Work
A student opens your educational application. They begin a ten-question science quiz. After answering seven questions, they switch to another application to check a message. Some time later, Android needs memory and terminates the quiz application’s background process.
When the student returns, Android recreates the application. The quiz opens. But every answer is gone. The student must start again. This isn’t necessarily a Compose rendering bug. It’s often a state-management problem.
Android applications need to distinguish between state that survives recomposition, state that survives configuration changes, state that can be restored after process death, and data that must remain available permanently.
Today, we’ll focus on one important technique: using SavedStateHandle to preserve lightweight ViewModel-owned state.










