How does DialogFragment affect the lifecycle of the calling Fragment?

mercavius picture mercavius · Mar 15, 2013 · Viewed 7.8k times · Source

I have a Fragment calling a DialogFragment. Does this affect the lifecyle of the Fragment (i.e. does it go to onPause)? When the DialogFragment is dismissed, does the calling Fragment go to onResume?

Answer

cstew picture cstew · Dec 10, 2015

Both of those fragments will be in the running state. onPause will not be called on the first fragment.

The lifecycle callbacks of Fragments (and Activities) work on an Activity level, not a fragment level. As an example, if you show an Activity that is themed to look like a dialog on top of the first fragment, then onPause will be called on that first fragment.

Fragments do not affect the lifecycle of other fragments.