About Me

My photo
Drum & Bass Producer, Software Developer, Love my Cats

How to disable BACK button in Android app


To override the back button in an Android application,
override the Activity method onBackPressed() to return

public class MyActivity extends Activity {

@Override
public void onBackPressed() {
return;
}
}

EDIT: 

Chintan commented that this snippet is also a solution:

@Override
public boolean onKeyDown(int keyCode,KeyEvent event) {
 if ((keyCode == KeyEvent.KEYCODE_BACK
    || KeyEvent.KEYCODE_HOME == keyCode
    || KeyEvent.KEYCODE_SEARCH == keyCode)){
  return false;
 }
 return super.onKeyDown(keyCode, event);