Describe the Android Activity lifecycle when navigating away and back

Tests understanding of resource management via lifecycle callbacks. A good answer traces onPause -> onStop -> onRestart -> onStart -> onResume, explaining what work happens in each.
What's really being asked
This isn't a test of rote memorization; it's a fundamental test of your ability to write safe, resource-efficient Android applications. The interviewer wants to know if you understand the state machine an Activity moves through and, more importantly, how to map application logic (like starting/stopping a network request or video player) to the correct lifecycle callback to prevent memory leaks, crashes, and poor user experience.
The full answer
An excellent answer describes the sequence and the purpose. First, when a user navigates away, the system calls onPause() followed by onStop(). Second, when the user returns to the activity, the sequence is onRestart(), then onStart(), and finally onResume(). Third, you must explain the distinction: onPause() is called when the activity is partially obscured (like by a dialog) and must be extremely lightweight. onStop() is called when the activity is no longer visible to the user. Fourth, you should describe what work belongs where: onPause() is for pausing animations or video. onStop() is for releasing expensive resources like a camera or network connections. onResume() is where you would re-acquire those resources.
The mistakes people make
A common mistake is forgetting onRestart() and incorrectly stating the sequence is onStop() -> onStart(). Another red flag is confusing the roles of onPause() and onStop(). Placing a heavy operation like saving to a database or releasing the camera in onPause() is incorrect; this method needs to execute very quickly (under a few milliseconds) because it blocks the UI thread and delays the appearance of the next screen. Finally, failing to mention state persistence via onSaveInstanceState() in the context of onStop() suggests an incomplete understanding of how to handle process death.
What usually comes next
Expect questions like: "Where does onSaveInstanceState() get called in this flow, and how does it differ from persisting data in onStop()?" or "What happens if the system kills your app's process while it's in the background?" or "How does this lifecycle change for a configuration change, like screen rotation?" or "How do Jetpack Lifecycle-Aware Components simplify this management?"
A concrete example
In a video player app, when a user navigates away: onPause() is called, and you should pause the video playback. Then onStop() is called; here you could release the media player and decoder resources entirely to free up memory. When the user returns: onRestart() is called, followed by onStart(), where you might re-initialize the media player. Finally, in onResume(), you would resume video playback from its last position, which you should have saved in onSaveInstanceState().
Interview question
When an Android Activity becomes completely invisible because the user navigated away, which lifecycle method is the most appropriate place to release expensive resources like a camera or network connection?
- a.onDestroy()
- b.onPause()
- c.onSaveInstanceState()
- d.onStop()Correct
Why? this is the answer
onStop() is the correct method because it is called when the Activity is no longer visible, making it suitable for releasing expensive resources. onPause() is incorrect as it must execute very quickly and is for pausing lightweight operations when the Activity is only partially obscured.
Just read this? Test yourself on what you have been reading.
Read the original → developer.android.com
- #android
- #activity
- #lifecycle
- #kotlin
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.
See open roles