Four startup modes for active (activity)

Source: Internet
Author: User

1. Standard mode

It is the default startup mode for the activity, which is automatically used by all activities without a display setting. Each time the activity is started by this mode, Android always launches a new instance for the target activity.

2. Singletop mode

It's a bit like standard mode, but it's different: In this mode, when the activity that is going to be started is already at the top of the task stack, the target activity instance is not recreated, but the existing activity instance is reused.

If the activity to be started is not at the top of the task stack, the system will recreate the instance of the target activity and load it on top of the task stack.

3. Singletask mode

Activity using this load mode has only one instance within the same task, which can be divided into three situations when the system launches activity using this singletask mode:

<1> if the activity that will be started does not exist, the target activity instance will be created and added to the top of the task stack.

<2> if the activity that will be started is already at the top of the task stack, this is the same behavior as the singletop mode.

<3> If the activity that is about to start already exists but is not at the top of the task stack, the system will move all activity above the activity out of the task stack, so that the target activity goes to the top of the stack.

4. SingleInstance mode

In this load mode, a target activity instance is created, regardless of the task from which it was started, and a new task stack is used to mount the activity instance. When the system uses SingleInstance mode to start activity, there are two situations:

<1> If the activity that is about to start does not exist, the system creates an entirely new task, creates an instance of the target activity, and adds it to the top of the new task's stack.

<2> If the activity that is about to start already exists, regardless of which application it is in, whatever task it is in, the system will take the activity's task to the foreground and use that activity to display it.

Tips: It should be noted that loading activity in singleinstance mode is always at the top of the task stack and loading the activity's task with SingleInstance mode contains only that activity.

Four startup modes for active (activity)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.