Activity start mode and activity start Mode
Activity can be started in four modes: standard, singleTop, singleTask, and singleInstance. Android manages Activity instances in the stack rollback mode. Stack is a collection of advanced and backward outputs. For example, if we open an Activity, the current display is at the top of the stack. When the user clicks back or the return button of the application, the system will output the Activity at the top of the stack, then the next Activity at the top of the original stack will change to the top of the stack and be displayed on the device. Standard default mode. You do not need to write configurations. In this mode, a new instance is created by default. Therefore, in this mode, you can have multiple identical instances and multiple identical activities. That is to say, multiple activities can exist in the same task stack. For example, if ActivityA already exists and ActivityA calls its startActivity () to start a new ActivityA, there are two ActivityA. SingleTop can have multiple instances, but does not allow the superposition of multiple identical activities. That is, if an Activity starts the same Activity at the top of the stack, it will not create a new instance, but reuse the Activity at the top of the stack and call its onNewIntent method. Singletop mode. If a new instance is started and is not at the top of the stack, a new instance will be created again, and its behavior will be the same as that in standard mode. SingleTask has only one instance. If the Activity does not exist when you start the Activity in the same application, a new instance is created in the current task. If the Activity exists, the destory of other activities in the task is deleted and its onNewIntent method is called. If you start it in another application, a new task is created and the Activity is started in the task. singleTask allows other activities to coexist with it in a task. That is, if I open a new Activity in this singleTask instance, the new Activity will still be in the task of the singleTask instance. SingleInstance has only one instance, and this instance runs independently in one task. This task has only one instance, and other activities are not allowed to exist. When this Activity is started again, existing tasks and instances are reused. Different from singleInstance, singletask has only one instance in a task. singleinstance can only have one instance in the system. singletask can have multiple instances in different tasks.