Four startup modes for Android activity

Source: Internet
Author: User

Four startup modes for Android activity

When the application is running, a thread is opened and a task stack is run on the thread, which is put into the task stack when the activity instance is created. The activity startup mode is set in the Androidmanifest.xml file by configuring the activity's Properties Android:launchmode= "" setting.

1. standared Mode (default)

The activity that we create directly is the activity of this mode, the activity of this mode is characterized by: as soon as you create an activity instance, once the activity is activated, a newly created instance is added to the task stack. Exiting the activity destroys the instance in the task stack.

2. Singletop mode

This mode takes into account whether the activity instance currently being activated is at the top of the stack in the task stack, and if it is at the top of the stack without recreating the new instance, the existing instance will be reused or a new instance will be created in the task stack.

3. Singletask mode

If there is an activity instance of the pattern in the task stack, the activity instance above that instance in the stack is removed, and the activity is reused by invoking the Newinstance () method of the instance, so that the instance is in the top position of the stack. Otherwise, re-create a new activity instance.

4. SingleInstance mode

When the mode activity instance is created in the task stack, the activity is reused by invoking the Newinstance () method of the instance as long as the instance is still in the task stack, that is, whenever the activity of that type is activated. The same activity instance is used at this point, and it will be at the top of the stack of the task stack. This mode is typically used to load slower, less expensive activity that does not need to be recreated every time.

Four startup modes for Android activity

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.