Android Core series--2, about task stacks (tasks)

Source: Internet
Author: User

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)

Related Article

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.