If the dialog is dismissed,I want to do something for my background.So I want to know if the dialog is dismissed
For me onCancelListener was the best option since I needed something that tracked an explicit closing of the dialog by clicking outside the alert area. Show activity on this post. When dialog closed, you can use dialog. setOnDismissListener at the following code with the usage of an updated dialog code.
tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog. Dismiss the fragment and its dialog.
You can use an onDismissListener
http://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html
public Dialog createDialog() { Dialog d = new Dialog(this); d.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(final DialogInterface arg0) { // do something } }); return d; }
If you are using a DialogFragment
just override onDismiss()
http://developer.android.com/reference/android/app/DialogFragment.html#onDismiss(android.content.DialogInterface)
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