Android tasks and rollback stacks-manage tasks

Source: Internet
Author: User

Android puts all started activities in the same stack as the previous one for management. For most applicationsProgramThis method works well, and you don't have to worry about how the activity is associated with the task or how they exist in the rollback stack. However, you may decide to break this common behavior. Maybe you want an activity in the application to start a new task (rather than in the current task) at startup, or when you start an activity, you want to use an existing instance (instead of creating a new instance at the top of the rollback stack), or you want to clear all activities other than the root activity in the rollback stack when the user leaves this task.

You can use the attributes in the <activity> list element and the identifier in the intent passed to the startactivity () method to do these tasks, or even more.

The main attributes of <activity> include:

Taskaffinity

Launchmode

Allowtaskreparenting

Cleartaskonlaunch

Alwaysretaintaskstate

Finishontasklaunch

Intent's main identifiers include:

Flag_activity_new_task

Flag_activity_clear_top

Flag_activity_single_top

In subsequent sections, you will see how to use these listing attributes and intent identifiers to define how an activity is associated with a task and its behavior in the rollback stack.

Warning:Most applications should not use the default behavior of terminal activity and task. If you decide that you must edit the default activity behavior, you must exercise caution and ensure the availability of the activity during startup and when you use the rollback button to return results from other activities and tasks. Make sure that the navigation result is consistent with the user's expected behavior.

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.