Suppose you have two operations A and B. You move from A to B. A goes to the background.
B is pushed onto the back stack, and B is focused. When you press the back button, activity B pops out of the back stack. Activity A resumes.
Note. Several tasks can be held in the background at once. However, if the user starts many background tasks at the same time, the system may begin to destroy background actions in order to restore memory, as a result of which the activity states will be lost. See the next section on activity status.
http://developer.android.com/training/basics/activity-lifecycle/starting.html Actions that have been destroyed must be recreated. Activity is destroyed and is recreated when the screen orientation changes.
http://developer.android.com/training/basics/activity-lifecycle/starting.html
http://developer.android.com/guide/components/tasks-and-back-stack.html You should see how the back stack works.
In your case, the finish should work for you (by clicking the "Back" button).
Note. The system calls onDestroy () after it has already called onPause () and onStop () in all situations except one: when you call finish () from the onCreate () method.
Suppose you have a third C action and want to go to Activity A.
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { onBackPressed(); } return super.onKeyDown(keyCode, event); } public void onBackPressed() { Intent myIntent = new Intent(ActivityC.this, MainActivity.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
source share