Four startup modes of Android Activity

Source: Internet
Author: User

When the application runs, a thread is enabled, and a job stack is run in the thread.ActivityAfter the instance is created, it is placed in the task stack.Activity startupThe mode is set inAndroidmanifest.XMLFile, through the configurationActivityAttributesAndroid: launchmode=""Set.

 

1.StandaredMode (default)

We usually createActivityAll in this modeActivityIn this modeActivityFeatures: as long as you createActivityInstance.ActivityWill add the newly created instance to the task stack and exitActivityThe instance is destroyed in the task stack.

 

2.SingletopMode

This mode will considerActivityWhether the instance is at the top of the stack in the task stack. If the instance is at the top of the stack, you do not need to create a new instance, and the existing instance will be reused. Otherwise, a new instance will be created in the task stack.

 

3.SingletaskMode

If this mode exists in the task stackActivityInstanceActivityRemove all instances.Newinstance ()Method ReuseActivityTo place the instance at the top of the stack. Otherwise, a newActivityInstance.

 

4.SingleinstanceMode

when the mode is activity after an instance is created in the task stack, as long as the instance is still in the task stack, that is, as long as the activated instance is of this type activity , all newinstance () Method reuse activity in this case, the same activity instance , all of which are at the top of the stack. This mode is generally used for loading slow, performance-consuming, and does not need to be re-created each time activity .

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.