Android:launchmode Overview

Source: Internet
Author: User

Android:launchmodean instruction on how the activity is should be launched. Thereis four modes this work in the conjunction with the activity flags (FLAG_ACTIVITY_ * constants) in Intent objects T o Determine what should happen when the activity was called upon to handle an intent. They is:' Standard ' "Singletop" "Singletask" "SingleInstance"default mode is " Standard ".

Activity has four startup modes, the default is standard type. Let's give a table and see it more clearly.

Use Cases Launch Mode Multiple Instances? Comments
Normal launches for most activities "Standard" Yes Default. The system always creates a new instance of the activity in the target task and routes the intent to it.
"Singletop" Conditionally If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance Through a call to its onnewintent () method, rather than creating a new instance of the activity.
Specialized launches (not recommended) "Singletask" No The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call T o its onnewintent () method, rather than creating a new one.
"SingleInstance" No Same as "Singletask", except that the system doesn ' t launch any and activities into the task holding the instance. The activity is always the A and only member of its task.

"Standard" can have multiple identical instances, and each time an activity is started, the system always creates a new instance of activity in the task stack and sets the path of intent for it.

Multiple instances of "singletop" are conditional, and if an activity instance already exists with the top of the task stack , the system calls its onnewintent () function to set the path to this instance for intent rather than creating a new identical instance.

The above two are commonly used.

The latter two are not commonly used.

"Singletask" has only one instance. In the current task stack, if the instance does not exist, one will be created, and if an instance of the activity already exists, the system will end all activity on it by calling its onnewintent () function to set the path to this instance instead of creating a new instance. If another program initiates the activity and the activity is already created in the current task stack, the instance is not created on that task stack, but the reference is used to point to the instance in the current task stack.

For example:

B is singletask mode

Operation: a->b a->b->c a->b->c->b a->b->c->b->c->a A-&G T B->c->b->c->a->b
Actual: A->b a->b->c a->b A->b->c->a A->b

The "singleinstance" activity always has an exclusive task stack. If you start B in a, the system opens up a task stack for B.

Android:launchmode Overview

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.