Android Learning notes---Android task stack and startup mode

Source: Internet
Author: User

1, an application is generally composed of multiple activity, task stack, record and store user-opened activity.

2, when an application is opened, the system will assign him to a task stack, when all the activity in the task stack exits, the task stack is emptied. The ID in the task stack is an integer data type (self-growing).

3, in the Android operating system there will be multiple task stacks, an application corresponding to a task stack.

4. By default, by shutting down an application, the system will empty the application. But the process of the application is also preserved

Why should I introduce the concept of a task stack?

In order to record what activity the user has turned on, and to record the order in which the activity was opened, Google introduced the task stack concept in order to have a better user experience.

You can specify the mode of the task stack in the activity's startup mode:

To configure the activity in Androidmanifest.xml:

<activity android:name= ". Mainactivity "android:launchmode=" singleinstance ">

Four modes of startup:

1, standard default boot mode, each time startactivity is to create a new activity instance

2, Singletop single top mode, if the activity to be opened already exists at the top of the task stack, it will not create a new instance, but use the top instance directly

3, Singletask a single task stack, if there is already an instance of the activity in the stack, reusing the instance will invoke the instance's Onnewintent (). When reused, the instance is returned to the top of the stack, so the instances above it will be removed from the stack. If the instance does not exist, a new instance is created into the stack. Note: Singletask mode activity Whether it is at the top or bottom of the stack, running the activity again, will destory off its activity to ensure that the entire stack only one, remember "This is beyond doubt."

4, SingleInstance Singleton Single instance mode, the entire mobile phone operating system only one instance exists, the activity is always at the top of the stack (because he is the only activity in the task), so always able to properly handle the behavior

  

(GO) Android Learning notes---Android task stack and startup mode

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.