Start Flag and Launchmode

Source: Internet
Author: User

(1) Flag_activity_new_task:

Action: Activity A starts the secluded task stack (stack state: A), starts activity B in activity A, and the flag of intent that initiates activity B is set to

Flag_activity_new_task, activity B is pressed into the stack (stack state: AB) where activity A is located. cause: By default, all activity in an app has the same relationship (taskaffinity).

B. Prerequisites: Activity A in an application named "TaskOne Application", activity C and Activity D are in an application named "Tasktwo app".

Action 1: Click the TaskOne app icon in launcher, Activity A launches the secluded task stack, named Taska (Taska stack State: A),

Starting activity C in activity A, the flag for intent with activity C is set to Flag_activity_new_task,

The Android system will open secluded a new task for activity C, named TASKB (TASKB stack State: C), press and hold the Home key, select Taska,

Activity a back to the foreground, start activity C again, then taskb back to the foreground, activity C display, for the user, that is:

A task that contains Flag_activity_new_task's intent start activity is running, and no new task is created for that activity.

Instead, the original task is returned to the foreground display.

(2) Flag_activity_clear_top:

Premise: Activity A, activity B, activity C and Activity D are in the same application.

Action: Activity A starts the secluded task stack (stack state: A), starts activity B in activity a (stack state: AB), starts in activity b

Activity C (Stack state: ABC), start activity D (Stack state: ABCD) in activity C, start activity B in Activity D,

The flag of intent that initiates ACTIVITY B is set to Flag_activity_clear_top, (stack state: AB).

(2) Flag_activity_clear_top:

Premise: Activity A, activity B, activity C and Activity D are in the same application.

Action: Activity A starts the secluded task stack (stack state: A), starts activity B in activity a (stack state: AB), starts in activity b

Activity C (Stack state: ABC), start activity D (Stack state: ABCD) in activity C, start activity B in Activity D,

The flag of intent that initiates ACTIVITY B is set to Flag_activity_clear_top, (stack state: AB).

(3) Flag_activity_brought_to_front:

If activity A is in an application named "TaskOne Application", activity C and Activity D are in an application named "Tasktwo app".

Action: Click the TaskOne app icon in launcher, Activity A launches the secluded task stack, named Taska (Taska stack State: A),

Starting activity C in activity A, the flag for intent with activity C is set to Flag_activity_new_task,

The Android system will open secluded a new task for activity C, named TASKB (TASKB stack State: C), starting in activity C

Activity D (Stack state of TASKB: CD), press and hold the Home key, select Taska, activity a returns to the foreground and activity C is activated again in activity a.

Set flag to Flag_activity_brought_to_front in intent starting ACTIVITY C, taskb back to the foreground,

Activity C shows, (TASKB stack state: C).

(4) Flag_activity_multiple_task:

Used in conjunction with Flag_activity_new_task, first set flag_activity_new_task in intent, open ACTIVITY,

Starts a new task, then sets Flag_activity_multiple_task in intent and opens the same ACTIVITY again, and a new task is started.

(5) Flag_activity_single_top:

There is an ABCD four activity in the current task stack, a is the top activity of the stack, and D is the bottom of the stack activity, which is set in the intent of open a

Flag_activity_single_top flag, the stack top A is used instead of the new new A.

(6) Flag_activity_reset_task_if_needed:

Example: There is activity a, activity B, activity C, activity A starts the secluded task stack, named Taska (Taska stack State: A),

Start activity B (Taska stack state: AB) in activity A, then activity B starts Activity C (Taska stack State: ABC),

Start ACTIVITY C by setting the Flag_activity_clear_when_task_reset title in the intent so that there is a restore point in the Taska

When there is a intent request Taska stack that contains flag_activity_reset_task_if_needed (e.g. request ACTIVITY A)

The system will clear the activity above the restore point, and only AB is left on the Taska stack.

4. Launchmode Introduction:

(1) Standard:

If the FLAG_ACTIVITY_NEW_TASK flag is not set in the intent that initiates this activity, the activity is in the same task as the activity that initiated it,

If the ACTIVITY is set, please refer to the above flag_activity_new_task for details, "Launchmode" is set to "standard"

The activity can be instantiated several times, and it can be instantiated at any point in the task for a new intent request.

(2) Singletop:

If the FLAG_ACTIVITY_NEW_TASK flag is not set in the intent that initiates this activity, the activity is in the same task as the activity that initiated it,

If you set up activity please refer to the above flag_activity_new_task details, "Launchmode" set to "singletop" activity can be

Instantiated multiple times, can be anywhere in a task, for a new intent request if at the top of the task stack, the activity intent request at the top of the stack is used,

Instead of instantiating the object to receive the request, if it is not at the top of the stack, a new object is instantiated to receive the intent request.

(3) Singletask:

The activity of "Launchmode" set to "Singletask" is always at the bottom of the stack and can only be instantiated once, allowing other activity to be pressed into the "singletask" activity

On the task stack, if there is a new intent request for activity with this flag, the system clears all activity in the task stack with this flag and displays the activity.

(4) SingleInstance:

Launchmode "singleinstance" activity is always at the bottom of the stack, can only be instantiated once, do not allow other activity to press "SingleInstance"

Activity on the task stack, which is the only activity in the entire task stack.

Start Flag and Launchmode

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.