When a new action begins, it is pushed onto the back stack and takes user focus. The back stack corresponds to the main mechanism of the βlast time for the first timeβ stack, therefore, when the user performs the current activity and presses the βBackβ button, it is ejected from the stack (and destroyed), and the previous action is resumed. The back button is pressed.
@Override public boolean onKeyDown(int i, KeyEvent event) { if (i == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent( YourActivity.this, New Activity.class ); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP ); startActivity( intent ); return true; } return super.onKeyDown(i, event); }
source share