Skip to content

Instantly share code, notes, and snippets.

@iggym
Forked from grantland/gist:1096474
Created September 5, 2013 16:11
Show Gist options
  • Save iggym/6452327 to your computer and use it in GitHub Desktop.
Save iggym/6452327 to your computer and use it in GitHub Desktop.
[...] = starting state
States:
not running (dead)
onResume (running)
onStop (minimized)
onPause (screen off)
Launch Application:
[not running|onStop] (onCreate|onRestart) -> onStart -> onResume
Press Home:
[onResume] onPause -> onStop
Press Back:
If back stack is empty:
[onResume] onPause -> onStop -> onDestroy
If back stack is not empty:
[B.onResume] B.onPause -> B.onStop -> B.onDestroy
-> A.onRestart -> A.onStart -> A.onResume
If back stack is not empty and previous activity was cleared for memory:
[B.onResume] B.onPause -> B.onStop -> B.onDestroy
-> A.onCreate -> A.onStart -> A.onResume
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
Freeing more memory:
[onPause] not running
[onStop] not running
[onDestroy] not running
Edge Cases:
onStart -> onStop
Open activity (onStart -> onResume) and open a dialog above it (onPause).
Press home (onStop) and reopen (onStart).
Press home (onStop)
No Activities in back stack
Pressing back to an activity that was cleared due to memory constraints
Reorienting root activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment