How can I make it so that pressing the back button does not close my application? I want to display a confirmation message.
Thank you.
Source: Override back button to act like home button
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//Display confirmation here, finish() activity.
return true;
}
return super.onKeyDown(keyCode, event);
}
That was a very quick search, try to look a little next time.