In order to capture or override the default back button press in Android the following onKeyDown method can be implemented by the Activity.

Code

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            moveTaskToBack(true);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

In case of Android 2.0+ a convenience method is provided as:

Code

    @Override
    public void onBackPressed() {
     
        // implement your override logic here
       return;
    }