Reputation: 417
The problem is that the onDismiss is not getting fired if I use FragmentsTransaction:
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// For a little polish, specify a transition animation
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
// To make it fullscreen, use the 'content' root view as the container
// for the fragment, which is always the root view for the activity
transaction.add(android.R.id.content, _dialogInfo).addToBackStack(null).commit();
but if I use show(), onDismiss event is called:
_dialogInfo.show(getFragmentManager(), DialogFragmentInfo.TAG);
The onDismiss is implemented at the custom DialogFragment like this:
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
}
Im not sure why is this and I did not find any explanation in the Documentation.
Upvotes: 3
Views: 1406
Reputation: 10326
From the DialogFragment, documentation, Lifecycle section:
This means you should use show(FragmentManager, String) or show(FragmentTransaction, String) to add an instance of DialogFragment to your UI, as these keep track of how DialogFragment should remove itself when the dialog is dismissed.
Presumably, show()
does some extra work to dismiss the dialog in the expected way.
Upvotes: 2