One of the four major components of Android: Activity startup mode

Why set the startup mode of Activity

    The activities placed in the stack will not be rearranged. If you do not want to create multiple instances of the same Activity, you must set the startup mode to achieve it.

Four start modes of Activity:

It can be changed by setting the launchMode property in the manifest file .

Standard (used doctrine): It is the default attribute value, no matter whether there is this Activity instance in the stack, a new Activity instance will be created.

singleTop (refused to stack): See if there is an instance of this on the top of the stack. If there is, call the onNewIntent method to reuse the Activity instance at the top of the stack. If not, create a new Activity instance.

singleTask (independent portal): first check whether there is an instance of this Activity in the stack. If there is, the onNewIntent method will be called to reuse the Activity instance at the top of the stack. At the same time, all other Activity instances located on this instance will be popped out of the stack and destroy. If not, create a new Activity instance.

singleInstance (lonely and lonely): The system will allocate a fallback stack for this Activity implementation separately, and other Activity instances cannot share a stack with him.




Guess you like

Origin blog.csdn.net/u010256329/article/details/51892006