Android-Startup mode

Source: Internet
Author: User

The Android startup mode is divided into four types:

    • Standard

mode startup mode, activity is created each time the activity is activated and placed in the task stack.

    • Singletop

If there is an instance of the activity at the top of the task, reusing the instance will create a new instance and put it in the top of the stack (even if the activity instance already exists on the stack, as long as it is not on top of the stack, an instance will be created).

    • Singletask

If an instance of the activity is already in the stack, the instance is reused (Onnewintent () of the instance is invoked). 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 in the stack, a new instance is created to be put into the stack.

    • SingleInstance

Create the activity instance in a new stack and have multiple apps share the activity instance in the stack. Once an instance of the activity in the schema is present on a stack, any application that activates the activity will reuse the instance in that stack, with the effect of sharing an app with multiple applications, regardless of who activates the activity into the same application.

Standard

Standard is the default startup mode for the system, and each time it is created, a new activity is placed on the heap.

There's not much to be introduced here.

Singletop

Each time a new activity is used, the current activity at the top of the stack is automatically detected as an activity that needs to be referenced, and if it is referenced directly, the activity is not created.

< Activity             Android:name =". Activity2 "            android:label=" Singletop "            android:launchmode=" Singletop ">        </activity>

The effect is that the top level is Singletop, and then clicking the Singletop button does not create a new activity.

Singletask

This startup mode and Singletop in the name can see the difference, that is, singletop only detect the current stack at the top of the activity is we need to request to create, and Singletask will detect the stack of all activity objects, from the top down, If it detects what we are requesting, it will destroy the object above the activity object and put the detected activity to the top of the stack directly.

< Activity             Android:name =". Activity4 "            android:launchmode=" Singletask "            android:label=" Singletask ">        </activity

The effect is to click Singletask after clicking on Multiple standard, then point singletask, those standard is gone.

SingleInstance

This startup mode works similarly to the browsers we use, and we all know that when accessing a browser in multiple programs, if the current browser is not open, the browser opens, otherwise it will be accessed in the currently open browser. This mode saves a lot of system resources because he can guarantee that the activity object to be requested only exists in the current stack.

I'm the dividing line of the king of the Land Tiger.

SOURCE Map:

Source code: HTTP://PAN.BAIDU.COM/S/1DD1QX01

Startup mode. zip

Reprint Please specify source: Http://www.cnblogs.com/yydcdut

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.