Can you walk me through the Android app lifecycle and how you've handled state management in your projects?

What the interviewer wants to learn

  • Your knowledge of Android components (Activity, Fragment, Service, etc.) and their lifecycle callbacks.
  • How you preserve UI state across configuration changes, process death, and background/foreground transitions.
  • Your ability to choose appropriate patterns (ViewModel, SavedStateHandle, Jetpack Navigation, etc.) and trade‑offs in real projects.

How to structure your answer

1. **Brief overview** – name the main lifecycle states and callbacks.

2. **State‑preservation strategy** – explain which Android Jetpack tools you use and why.

3. **Concrete project example** – describe a specific screen, the problem you faced, and the solution you implemented.

4. **Result** – mention the impact (fewer crashes, smoother UX, easier testing).

Example answer

“Sure. An Activity moves through onCreate → onStart → onResume → onPause → onStop → onDestroy, with onSaveInstanceState called before onStop when the system might kill the process. For fragments, the callbacks mirror the activity but add onCreateView and onViewCreated. In my last project I had a multi‑step form that needed to survive rotation and background‑kill scenarios. I used a ViewModel to hold the form data in memory and a SavedStateHandle inside the ViewModel to automatically persist it via onSaveInstanceState. When the activity recreated, the ViewModel was restored and the UI repopulated from the SavedStateHandle, so users never lost their progress. This reduced crash reports by 30 % and made the codebase easier to unit‑test.”

Mistakes to avoid

  • Reciting the lifecycle without linking it to a real problem you solved.
  • Saying you “store everything in static variables” or “re‑load from the network on every rotation.”
  • Ignoring newer Jetpack components (ViewModel, SavedStateHandle, Flow) and relying only on old patterns like onRetainNonConfigurationInstance.
  • Over‑complicating the answer with unrelated details (e.g., deep dive into Dagger modules).

More system design questions