Skip to content

Instantly share code, notes, and snippets.

@getsadzeg
Last active March 29, 2019 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getsadzeg/2c66bd0e70e900fa906e34950ba1a873 to your computer and use it in GitHub Desktop.
Save getsadzeg/2c66bd0e70e900fa906e34950ba1a873 to your computer and use it in GitHub Desktop.
Understanding Android Lifecycle
  • onCreate -> Builds UI. Activity is created.

  • onStart -> Activity is visible.

  • onResume -> Becomes active foreground app.

In reverse:

  • onPause -> Activity has lost focus(for example, if it's partially obscured: a dialog pops up or whatever).

  • onStop -> No longer visible(completely obscured, moved to the background).

  • onDestroy -> Activity is destroyed, indicating the end of activity lifecycle.

And, plus, if we hit home and relaunch the app(not destroying it; without being recreated) we get extra state, onRestart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment