Activities (activity) four startup mode

1. standard mode

       It is the active default boot mode, without displaying the development of all activities will start automatically use this mode. Each time through this mode to start the activity, android is always a target activity to start a new instance.

2. singleTop mode

       It is somewhat similar to standard mode, but it is a little different: when in this mode to be activated when activity has been found in the Task top of the stack, the system does not re-create the instance of the target activity, but the activity reusing existing instance.

       If you are going to start the activity is not in the Task top of the stack, then the system will re-create the instance of the target activity, and load it onto the Task stack.    

3. singleTask mode

       This loading pattern is used in the same activity Task only one instance, when the system is employed in this mode is activated singleTask activity, can be divided into three cases:

       <1> If you want to start the activity does not exist, the system will create the target activity instance, and add it to the Task stack.

       <2> If the activity to be started already in the Task stack, this time with the same behavioral patterns singleTop.

       <3> If the activity to be started already exists, but is not in the Task top of the stack, the system will put all of the activity is located out of the above activity Task stack, so that the top of the stack into the target activity.

4. singleInstance mode

       In this loading mode, no matter from which Task start the target activity, the goal will only create an instance of activity, and will use a new Task stack to load the activity instance. When the system mode is started using singleInstance activity, it can be divided into two situations:

       <1> If you want to start the activity does not exist, the system will create a new Task, and then create an instance of the target activity, and add it to the new Task top of the stack.

       <2> If you want to start the activity already exists, no matter which application it is located, whether it is located in which Task, the system will be the Task of the activity is located to the foreground in order to use the activity displayed.

       tips: It should be noted that the use of singleInstance mode load activity always in the Task top of the stack, using singleInstance load mode where the Task activity contains only the activity.

Reproduced in: https: //my.oschina.net/u/2448419/blog/512471

Guess you like

Origin blog.csdn.net/weixin_33814685/article/details/92291329