Skip to content

Instantly share code, notes, and snippets.

@grantland
Created July 21, 2011 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save grantland/1096474 to your computer and use it in GitHub Desktop.
Save grantland/1096474 to your computer and use it in GitHub Desktop.
Android Activity Lifecycle
[...] = starting state
States:
not running (dead)
onResume (running)
onStop (minimized)
onPause (screen off)
Launch Application:
[not running|onStop] (onCreate|onRestart) -> onStart -> onResume
Press Back:
If activity stack is empty:
[onResume] onPause -> onStop -> onDestroy
If activity stack is not empty:
[B.onResume] B.onPause -> B.onStop -> B.onDestroy
-> A.(onRestart|onCreate) -> A.onStart -> A.onResume
Press Home:
[onResume] onPause -> onStop
Turn Off Screen:
[onResume] onPause
Turn On Screen:
[onPause] onResume
Calling startActivity:
-> B.onCreate -> B.onStart -> B.onResume
[A.onResume] A.onPause -> A.onStop
Rotating
[onResume] onPause -> onStop -> onDestroy -> onCreate -> onStart -> onResume
onStart -> onStop
Open activity (onStart -> onResume) and open a dialog above it (onPause).
Press home (onStop) and reopen (onStart).
Press home (onStop)
Freeing more memory:
[onPause] not running
[onStop] not running
[onDestroy] not running
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment