I am developing an application that when the button is pressed, it opens a dialog with OK and Cancel buttons.
It works fine.
When the user presses the back b
Override method onBackPressed() in your own dialog and use it in your code:
onBackPressed()
public class MyDialog extends Dialog { public MyDialog(@NonNull Context context) { super(context); } @Override public void onBackPressed() { // Do what you want } }
Use:
MyDialog dlg = new MyDialog(context); dlg.show();