One, the task
A task is a stack of interface components that can come from multiple processes, multiple applications, and exist for a common task, such as writing messages that use interface components in mail applications and contact apps that run on the same task.
Second, the operating mode of the interface component
1,standard Standard mode, each call interface component will generate a new instance pressed into the stack top of the task stack.
2,singletop, corresponding to Activity_flag_activity_single_top, if the current interface component at the top of the stack, then call the interface component again will not generate a new instance, but directly using the top of the stack interface components, through the Onnewintent method will The intent object is passed to the interface component. However, if the interface component is not on top of the stack, a new instance is generated at the top of the stack.
3,singletask and SingleInstance, when invoking the interface component of this run mode, launches a new task (if not yet started), placing the interface component on the bottom of the stack. If the interface component is called again, the interface component is emptied and reused again.
SingleInstance is a little different, that is, there is only one interface component in the new task, and Singletask is a number of other interface components in the new task.
Use Singletask also note: If the interface component set the task Viscosity property, Android:taskaffinity property, then the interface component must not necessarily be the root component, if the specified task already exists, it will jump directly to the specified task.
Three, task viscosity android:taskaffinity properties
Indicates which task the interface component wants to run in, it is useless to set the property separately, and one of the following items needs to be set:
1, set android:allowtaskreparenting = "true"
2, by setting the Activity.flag_activity_new_task tag.
Four, example:
1, Android native app: Browser app
Its interface component browseractivity is configured as Singletask, and android:alwaysretaintaskstate = "true" is set, which indicates that the task state is always maintained.
2, Contact application:
By android:taskaffinity the contact management, the call management related interface components are placed in separate tasks.
Reference:
"Essentials of Android Development" Fan Whiyu
Android Core series--2, about task stacks (tasks)