If I launch a DialogFragment from an activity, what happens when I close the DialogFragment? Does the activity go through onResume state? Or is the call as any normal java call so that the next line is never executed until the DialogFragment is closed?
Suppose the method for launching my fragment is
private void launchFragment(){
ConfirmationDialog confirm = new ConfirmationDialog();
confirm.show(getSupportFragmentManager(), "confirm");
doMoreStuff();
}
So my question is twofold:
doMoreStuff()
called? Before or after I close the fragment to return to the parent activity?As in the following example:
@Override
public void onResume() {
super.onResume();
if(dialogFragmentChangedThis){
workSomeMore();
}
}
The fragment is launched with
setStyle(STYLE_NO_FRAME, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
so that it is in fullscreen mode.
When is doMoreStuff() called? Before or after I close the fragment to return to the parent activity?
DialogFragment
's show()
method just commits a FragmentTransaction
, which will be executed asynchronously, so any method that follows it will be executed immediately.
After I close the fragment to return to the parent activity, does the parent activity go through onResume
No, it doesn't, since your Activity
is in foreground all the time, as there are no other Activities
involved.
Usually you'll use the Callbacks listeners with DialogFragment
s as you do with simple Fragment
s, by implementing the Callbacks in your Activity
and by calling your Activity
's method through that interface when you want to pass a result of an action that happened in the DialogFragment
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With