Android Startup Mode and Android Startup Mode

Source: Internet
Author: User

Android Startup Mode and Android Startup Mode

In simple terms, the startup mode is the policy when the Activity is started. In AndroidManifest. xml, the android: launchMode attribute of the <Activity> tag is set;

There are four startup modes: standard, singleTop, singleTask, and singleInstance;

Activity Startup Mode settings:

<Activity android: name = ". MainActivity" android: launchMode = "standard"/>

Four startup modes of Activity:

1. standard

In startup mode, the Activity is created every time the Activity is activated and placed in the task stack.

2. singleTop

If an instance of the Activity exists at the top of the stack of the task, the instance is reused. Otherwise, a new instance is created and placed on the top of the stack (even if the Activity instance already exists in the stack, instances will be created as long as they are not at the top of the stack ).

3. singleTask

If an instance of the Activity already exists in the stack, the instance will be reused (onNewIntent () of the instance will be called ()). When it is reused, the instance will be sent back to the top of the stack, so the instance on it will be removed from the stack. If this instance does not exist in the stack, a new instance is created and put into the stack.

4. singleInstance

Create the Activity instance in a new stack and share the Activity instance in the stack with multiple applications. Once an instance of a modified Activity exists in a stack, any application that activates or changes the Activity will reuse the instance in the stack. The effect is that multiple applications share one application, no matter who activates the Activity, it will enter the same application.

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.