Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does DialogFragment affect the lifecycle of the calling Fragment?

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?

like image 879
mercavius Avatar asked Mar 15 '13 02:03

mercavius


2 Answers

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.

like image 141
cstew Avatar answered Nov 19 '22 08:11

cstew


The Dialog fragment will be present in a Dialog window above your activity with a Fragment. The Activity and the Fragment will not change their state.

like image 20
geNia Avatar answered Nov 19 '22 08:11

geNia