Flag for activating activity in intent
The intent class defines a batch of constants that are used to configure relevant parameters when activating activity;
Set flag in intent
• Call Intent's setflags () or addflags () to configure the flag property of the intent
Property Value Description:
Flag_activity_new_task
• Attempts to open a new task may result in:
(1) If the currently existing task is the same as the taskaffinity of the activity you are trying to activate, press the stack directly in the task,
The active activity gets the top position of the stack;
(2) If no task is currently in the same taskaffinity as the activity that you are trying to activate, create a new task
And the active activity gets the top position of the stack.
For example:
· Activitya and Activityb exist in App1, the current Activitya has been activated by APP2
Activate the App1 activityb, go back to the desktop and click on the App1 icon, will directly show Activityb, throughout the process, APP1
The 2 activity's task ID is the same, APP2 's activity is another task ID.
Flag_activity_clear_task
• Empty the task that the active activity should belong to, and the active activity is added to the task to get the top position of the stack
• The flag should be used with flag_activity_new_tast
Flag_activity_single_top
• Located at the top of the stack is unique, its characteristics can be referred to the <activity> Launchmode property configured as Singletop
But the difference is that flag settings are relatively live and can be set dynamically, while Launchmode settings are relatively dead
Flag_acitvity_clear_top
• To clear the top, the effect may result:
• Scenario 1: When an instance of intent attempts to activate activity does not exist in the task, the instance of the activity is created and
Get the top position of the stack;
Scenario 2: If an instance of the activity already exists, clears all activity above that instance in the task, and
Get the top position of the stack;
Scenario 3: On the basis of scenario 2, if the activity's Launchmode property is not
Singletask or SingleInstance, an instance of the activity's original existence will also be removed, at the top of the stack is the newly created instance of the activity
Flag_activity_clear_whea_task_reset
• When the task is reset, clears the activity and all activity that is above the activity in the task
• When a TASK is placed in the background and is re-placed in the foreground, it may be reset (added flag_activity_reset_task_if_needed by the system).
It is usually reset when you go back to the foreground by clicking on the application icon, but not through the task list.
Flag_activity_no_history
。 When the activity is placed in the background, whether it is purged from the back stack and ended, its properties can refer to the <activity> Nohistory property
Setting the startup parameters using the intent flag