1. Standard
Standard mode, which is the default startup mode for the activity, which is automatically used by all activities without displaying the specified condition.
Android uses the return stack management activity, in standard mode, whenever a new activity is started, it is placed in the stack on the back of the stack and at the top of the stack.
For example:
1 Public classFirstactivityextendsappcompatactivity {2 @Override3 protected voidonCreate (Bundle savedinstancestate) {4 Super. OnCreate (savedinstancestate);5 //Prompt Information6Toast.maketext ( This, "firstactivity" + This, Toast.length_short). Show ();7 Setcontentview (r.layout.activity_first);8Button BTN =Findviewbyid (R.ID.BTN1);9Btn.setonclicklistener (NewView.onclicklistener () {Ten @Override One Public voidOnClick (View v) { AIntent Intent =NewIntent (firstactivity. This, Firstactivity.class); - startactivity (intent); - } the }); - } -}
Firstactivity.java
As you can see from the output information, when you click New Activity, a new event is created and the OnCreate method is executed.
2. Singletop
If you want to start an activity, the activity will not be created again at the top of the stack, and the activity will still be created if the activity is not on top of the stack.
There may be times when the absolute standard mode is not very reasonable, the activity is already on the top of the stack, why do you want to start a new activity?
Set to Singletop mode:
1 <activity android:name= ". Firstactivity "2 android:launchmode=" Singletop ">3 <intent-filter>4 <action android:name= "Android.intent.action.MAIN"/>5 <category android:name= " Android.intent.category.LAUNCHER "/>6 </intent-filter>7 </activity>
3.singleTask
The goal is to have an activity that only has one instance in the context of the entire application . Each time the activity is started, the system first checks to see if the activity is present in the return stack, only if it does not exist, and if found, uses the return stack activity directly.
4.singleInstance
Start a new return stack to manage this activity.
To implement multiple program sharing activities, multiple applications share this return stack.
Startup mode for Android activity