1. Preface
The demo analysis references the mapdigit article about API demos. On the basis of this article, I further analyzed related knowledge points.
2. Demo
3. Demo Analysis
Android applications can contain multiple activities. One activity can start another activity. These activities are managed using the stack structure. Newly opened activities are stacked on the current activity, and the current activity stops running. When an activity stops running, the android system retains its status before it stops. When you press the "back" button, the activity at the top of the stack is pushed back from the top of the stack, the previous activity is moved to the top of the stack and displayed on the screen:
Sometimes, when an activity starts a new activity, it does not want to keep the current activity in the activity stack. For example, when the activity is used to implement a confirm dialog, when the user confirms and starts a new activity, the user does not want to display the confirm dialog when the new activity is displayed after "back.
In the example, fowarding uses finish () to end the current activity while starting the new activity.
Intent intent = new Intent(); intent.setClass(Forwarding.this, ForwardTarget.class); startActivity(intent); finish();
Finish the forwarding activity, and then press "back" to return to the apidemo-> activity sample list instead of forwarding.
4. Video Explanation:
Http://www.eyeandroid.com/thread-9716-1-1.html
5. We learned the following demo:
1. Four methods to exit the Android Application
Http://www.eyeandroid.com/thread-9701-1-1.html