In Android, each interface is an Activity, and switching interface operations are actually instantiated operations between multiple different activities. The startup mode of Activity in Android determines the startup and operation of Activity.
Activity has four startup modes:
1. standard,In the default startup mode, as long as the Activity is activated, a new instance will be created and placed in the task stack, so that there may be multiple instances of an Activity in the task stack at the same time.
2. singleTop,When activating the activity, if the top of the stack is this activity, no new instance will be created; if the top of the stack is not this activity, a new instance will be created.
3. singleTask,If there is an instance of Activity on the stack, remove the instance of other Activity above that instance on the stack, so that the instance of the Activity is at the top of the stack; if there is no instance in the stack, create a new instance.
4. singleInstance, multiple applications share an instance of the Activity. Regardless of whether it is the same application, as long as the Activity is activated, this instance will be reused.
You can set the startup mode for the Activity in the specific method is to set the android:launchMode property.
Some applications need to jump back and forth in two forms, such as A-->B, B-->A,.... At this time, the startup mode of A and B needs to be set to singleTask. Otherwise, when the return key is pressed, it will also jump back and forth in two forms A and B.
The above content is the four startup modes of Activity in Android introduced to you by the editor. I hope it will be helpful to everyone!