xxv / android-lifecycle

A diagram of the Android Activity / Fragment lifecycle
5.26k stars 681 forks source link

Lifecycle when starting another Activity #3

Open landakram opened 10 years ago

landakram commented 10 years ago

First of all, this is awesome. Spotted it in Android Weekly, and it is much more comprehensive than the lifecycle diagram in the Android docs.

It would be awesome to include the order of lifecycle events when another Activity is started. According to the docs, the order of events in a single application is well defined:

  1. Activity A's onPause() method executes.
  2. Activity B's onCreate(), onStart(), and onResume() methods execute in sequence. (Activity B now has user focus.)
  3. Then, if Activity A is no longer visible on screen, its onStop() method executes.

However, I haven't verified this myself (or seen the info reproduced anywhere else).

xxv commented 10 years ago

@landakram Included in this repo is a quick app that just logs all the lifecycle events (the entry and exit from the callbacks). With a little tweaking, you could verify it those lifecycle events.

This diagram is for what happens within an individual Activity. It may be interesting to have what you're describing, but it'd need to be a separate diagram.