Standard mode: The default starting mode, without setting, all activities will automatically use this mode. Android uses the task stack to manage the activity, and in this mode, whenever a new activity is started, it is placed in the stack on the task stack and at the top of the stack. For this mode, the system does not care whether the activity is already in the stack, and each startup creates a new instance of the activity.
Packagecom.pingyijinren.helloworld.activity;Importandroid.content.Intent;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.Button;ImportCOM.PINGYIJINREN.HELLOWORLD.R; Public classMainactivityextendsAppcompatactivityImplementsView.onclicklistener {Privatebutton button; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Button=(Button) Findviewbyid (R.id.button); Button.setonclicklistener ( This); } @Override Public voidOnClick (View v) {startactivity (NewIntent ( This, Mainactivity.class)); }}
A new activity is generated each time a button is clicked, at which time there are four mainactivity in the back stack and four times in a row to exit the program.
Singletop mode: When the activity is at the top of the stack and already exists, it is no longer in the stack (no longer creates an activity), and when it is not at the top of the stack, it continues into the stack.
Singletask mode: The use of this mode can be a good solution to the problem of duplicate creation of the top of the stack, when the active startup mode is specified as Singletask, each time the activity is started, the system will first check the task stack for the existence of the active instance, if the discovery already exists then directly use the instance, And the activities above the activity are all out of the stack, if not found to create an instance.
SingleInstance mode: Activities specified as singleinstance mode enable a new return stack to manage this activity (in fact, a new return stack is started if the Singletask mode has a different taskaffinity).
Activity startup mode