xxv / android-lifecycle

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

Activity.onPause() is called after Fragment.onPause() #9

Open xxv opened 10 years ago

xxv commented 10 years ago

Fragment.onPause is called before Activity.onPause; ditto for onStop

(Reported by Kurt Huwig via personal email)

xxv commented 10 years ago

v19 lifecycle goes:

I/LifecycleLog(28061): TestFragment.onPause / →☐
I/LifecycleLog(28061): TestFragment.onPause / ☐→
I/LifecycleLog(28061): MainActivity.onPause / →☐
I/LifecycleLog(28061): MainActivity.onPause / ☐→

whereas the compat library goes:

I/LifecycleLog(28061): MainFragmentActivity.onPause / →☐
I/LifecycleLog(28061): TestCompatFragment.onPause / →☐
I/LifecycleLog(28061): TestCompatFragment.onPause / ☐→
I/LifecycleLog(28061): MainFragmentActivity.onPause / ☐→
ekux44 commented 8 years ago

In my (very limited) testing, it seems that recent versions of the appcompat library pause fragments before activities.

milosmns commented 7 years ago

@ekux44 Calling super.onWhatever() inside all Activity lifecycle callbacks will invoke those lifecycle events on the Fragment Manager, and thus forwarding those events to each of the living fragments.