I have a dialog in an Android app that I don\'t want the user to be able to cancel. Using .setCancelable(false)
disables the back button, but pressing the sear
@Benh You need this code to set for your Key Listener for Dialog
builder.setOnKeyListener(keylistener);
Add Below code in your Activity Class
OnKeyListener keylistener=new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
return true; //we stop begin cancel of dialog or Progressbar
}
return false;
}
};
try this above thing in your dialog hope that will work for you.