Android Task Stack and Startup Mode

Source: Internet
Author: User

Android Task Stack and Startup Mode
1. An application is generally composed of multiple activities.
2. The task stack (alias back stack) records the activities enabled by the user.
3. Once an application is enabled, a task stack is assigned to it. When all the activities exit, the task stack is cleared.
4. the id of the task stack is an integer whose data type increases by itself.
5. There will be multiple task stacks in the android operating system, one application and one task stack.
6. desktop applications are the same as general applications, and the same is true for task stacks.
7. By default, an application is closed and the task stack of the application is cleared. The process of the application is retained.




Why should we introduce the concept of Task Stack:
In windows, you can click the taskbar to switch tasks.
Switch the task of holding a small house in android


In order to record the sequence in which activities are enabled and recorded by users, google introduces the task stack concept to help maintain a good user experience.






Activity Startup Mode:

Configure the specified Activity in AndroidManifest. xml:

Android: launchMode = "singleInstance"
>

1. standard default standard startup mode. Every startActivity creates an instance of a new activity.
Applicable to the vast majority of cases
2. singleTop: if the activity to be enabled already exists at the top of the job stack, no new instances will be created,
Instead, the onNewIntent () method is called.
Application Scenario: browser bookmarks. Avoid repeated creation of the activity at the top of the stack to solve user experience problems.
3. singletask is a single task stack. activity only has one instance in the task stack. If you want to activate the activity
If the task stack already exists, it will not create a new activity, but reuse the existing activity,
Call the onNewIntent () method and clear all the activities on the activity stack.
Application Scenario: browser activity, the entire task stack has only one instance, saving memory and cpu
Note: The activity is still running in the task stack of the current application. No new task stack will be created.


4. singleInstance single-State singleInstance Mode
For a single instance, only one instance exists in the mobile phone operating system. Different applications open this activity
Share a common activity.
It runs in its own independent task stack, and only one of its instances exists in the stack.
Application Scenario: InCallScreen

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.