I have an AlertDialog
. I can get notified when the dialog is cancelled by installing a DialogInterface.OnCancelListener
. However, I don't see any way to stop Android from automatically closing the dialog when the user presses the BACK button or taps outside of the dialog area.
Suppose that whenever the user tries to cancel dialog I want to show another dialog that asks "Are you sure you want to close this dialog?". I thought I could implement this in onCancel()
in DialogInterface.OnCancelListener
but it doesn't work because Android always automatically dismisses the dialog. Is there a way to stop Android from doing that so that I can choose whether I want to dismiss it or not?