Skip to content Skip to sidebar Skip to footer

What Is Lifecycle Of Dialogfragment

I could not find proper lifecycle of android.support.v4.app.DialogFragment by searching on Google. I need this for some implementation. As we know DialogFragment has some methods s

Solution 1:

DialogFragment life cycle is similar to the life cycle of fragment:. To test yourself put logs in each of the overrided methods of dialogFragment and then run your code you will understand the working of dialogFragment.

onAttach
onCreate
onCreateDialog
onCreateView
onActivityCreated
onStart
onResume

And as far as finishing or destroying dialogFragment is concerned the lifeCycle is as follows:

onPause
onStop
onDestroyView
onDestroy
onDetach

Also I believe this method will also help you know the lifecycle :

@NonNull@Override
public Lifecycle getLifecycle() {
    returnsuper.getLifecycle();
}

Solution 2:

Solution 3:

DialogFragment does various things to keep the fragment's lifecycle driving it, instead of the Dialog. Note that dialogs are generally autonomous entities -- they are their own window, receiving their own input events, and often deciding on their own when to disappear (by receiving a back key event or the user clicking on a button).

Source : https://developer.android.com/reference/android/app/DialogFragment#lifecycle

Post a Comment for "What Is Lifecycle Of Dialogfragment"