Activity four startup Modes 2

Source: Internet
Author: User

One: Standard startup mode

Standard is the default mode each activity starts with an activity in the stack, and the same will be added.

So how many times will you have to press the back button to get back to the original interface?

II: Singletop startup mode

1. Checklist Configuration:

<activity

Android:name= "Com.itcode.taskstack.SecondActivity"

Android:label= "@string/_second"

Android:launchmode= "Singletop" >

</activity>

Singletop: If there is already an instance of this activity at the top of the stack,

Does not create new activity, but instead uses the old activity instance

Call the old activity's Onnewintent () method

2. Function:

Avoid a bad user experience, if the interface is already open and at the top of the stack of tasks, it will not be opened repeatedly

Three: Singletask startup mode:

1.Androidfest configuration:

<activity

Android:name= "Com.itcode.taskstack.SecondActivity"

Android:label= "@string/_second"

Android:launchmode= "Singletask" >

</activity>

2. Function:

Singletask startup mode: Only one instance is allowed to exist in the task stack, if 02 is Singletask,

Stack: 01 02 01 03 If you turn on 02 at this point, the existing activity is reused and the other activity above the current activity is emptied from the task stack!

3. Application Scenario:

Browser: The underlying use of the WebKit C kernel, initialization needs to request a lot of memory resources, CPU time

So use Singletask to ensure that only one instance exists in the task stack.

Four: SingleInstance startup mode (equivalent to instance):

Configuration of 1.Androidfest:

<activity

Android:name= "Com.itcode.taskstack.SecondActivity"

Android:label= "@string/_second"

Android:launchmode= "SingleInstance" >

</activity>

2. Features:

SingleInstance's boot mode is more extreme,

Start a new activity and create a separate task stack for yourself

3. Application Scenario:

There will only be one instance of the activity in the entire mobile operating system,

So multiple applications share this activity instance, thread security issues!


Activity four startup Modes 2

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.