xxv / android-lifecycle

A diagram of the Android Activity / Fragment lifecycle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

xxv opened this issue · comments

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

(Reported by Kurt Huwig via personal email)

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 / ☐→

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

@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.