Android Activity Startup mode

Source: Internet
Author: User

The android boot mode is the operating mode of the activity task stack: The task stack is used to store activity

The Android:launchmode property of the label in the Androidmanifest.xml setting Activiy the startup mode, the default startup mode is standard;

Activity has four kinds of start-up modes: Standard, Singletop, Singletask, singleinstance, respectively;

Task stack:

Each application has a task stack, which is a stack of functions similar to that of a function call, and the order represents the order in which the activity appears; For example, Activity1-->activity2-->activity3, the task stack is:

Now let's talk about his startup mode:

First, Standard

(1) Standard: Every time the activity is activated (startactivity), the activity instance is created and put into the task stack;

(2) Singletop: If an activity itself activates itself, that is, the task stack top is the activity, you do not need to create, the rest of the case to create activity instances;

(3) Singletask: If the activity to be activated in the task stack exists in the instance, you do not need to create, just need to put this activity into the top of the stack, and the activity of the activity above the instance of pop;

(4) SingleInstance: If Mainactivity instance is created in the task stack of application 1, if Application 2 also activates mainactivity, then no need to create, two apps to share the activity instance;

Application of Singtask:

can be used to exit the entire application.

Set the main activity to Singtask mode, then transfer the activity to the main activity in order to exit, then rewrite the onnewintent function of the main activity and add a finish to the function.

Android Activity 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.