The Activity lifecycle

Lifecycle and app components Junior Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Order the steps

Order the callbacks when an app is opened from the launcher and then sent home.

  • onResume
  • onCreate
  • onStart
  • onPause
  • onStop

Choose an answer, then open Show answer below to check it.

Show answer

Answer: B C A D E

  1. onCreate Created; set content and read saved state.
  2. onStart Visible.
  3. onResume In front and interactive.
  4. onPause Home pressed: losing the foreground.
  5. onStop No longer visible. onSaveInstanceState follows on Android 9+.

30-second answer

onCreate sets up the UI and reads saved state. onStart means visible; onResume means in front and taking input. onPause means losing focus, which also happens in multi-window or when a dialog-style Activity appears. onStop means no longer visible, and onDestroy means finishing or being recreated. Keep onPause fast; save work in onStop or continuously.

Practise saying it · 45 s. No recording, just a timer

Explain the Activity lifecycle.

Say your answer out loud, then check which of these points you covered:

  • Three pairs: create/destroy, start/stop, resume/pause
  • Keep onPause fast
  • onDestroy may never run
  • Use lifecycle-aware components

Deep dive

In multi-window on Android 10 and later, every visible Activity is resumed; the one with focus is reported by onTopResumedActivityChanged. Tie visibility-based work to start/stop.

isFinishing and isChangingConfigurations tell you why onDestroy is called.

onSaveInstanceState runs after onStop on Android 9 and later.

Lifecycle-aware components (DefaultLifecycleObserver, repeatOnLifecycle) keep this logic out of the Activity.

Common mistakes

  • Doing slow work in onPause, which delays the next Activity.
  • Assuming onDestroy is always called; the process can be killed without it.
  • Starting collection in onResume without stopping it.

Senior take & follow-ups

Pair the callbacks (create/destroy, start/stop, resume/pause) and say what each pair means: created, visible, in front.

Follow-up questions

Think of your answer first, then open the hint.

  1. When is onDestroy not called?

    Show hint

    When the system kills the process, for example in the background.

  2. Why is onPause kept short?

    Show hint

    The next Activity's onResume waits for it.

Similar on iOS: App and scene lifecycle states iOS has scene states (active, inactive, background) rather than per-screen callbacks.

Suggest a fix if something here is wrong or out of date.