How to catch event with hardware back button on android ? I need to supress user to go back and I when click on back button on phone to show message and not to go on previou
You can suppress user "back" action with onKeyDown() in your activity like this:
onKeyDown()
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { //do actions like show message return false; } return super.onKeyDown(keyCode, event); }