FresherTechnicalMobile platform
Describe the mobile app lifecycle states
Try answering first
Model answer
A mobile app moves between a few states as the user and the OS act on it. The names differ slightly per platform, but the idea is the same.
- Not running: the process does not exist.
- Foreground / active: the app is visible and receives input.
- Inactive: visible but not receiving events, for example during a phone call or when a system dialog appears.
- Background: the app is not visible. It has limited time to run, and the OS may suspend it.
- Suspended / killed: the OS can reclaim memory and terminate the process without warning.
On Android, activities also have callbacks such as onCreate, onStart, onResume, onPause, onStop and onDestroy. In React Native, AppState reports active, background and, on iOS, inactive.
Save important state when the app goes to the background, because it may be killed before the user returns.
Key points
- States: not running, active, inactive, background, suspended
- The OS can kill a background app at any time
- Android activities add callbacks such as onPause and onStop
- Persist state when moving to the background
Likely follow-ups
- What do you do when the OS kills your app in the background?
- How would you pause a video when the app goes to the background?
Common mistakes
- Assuming the app keeps running in the background
- Keeping state only in memory and losing it when the process dies