How would I override a Dialog
's onBackPressed
to close the dialog as well as calling finish()
on the Activity
it is located in?
You can use setOnCancelListener
:
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { MyActivity.this.finish(); } });
You need to finish only your activity. Dialog will be dismissed automatically.
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