Android activity startup mode, androidactivity

Source: Internet
Author: User

Android activity startup mode, androidactivity

There are four startup modes for an activity: standard, singleTop, singleTask, and singleInstance. You can select the startup mode by specifying the android: launchMode attribute for the <activity> tag in AndroidMannifest. xml.

1. standard

It is the default startup mode of the activity. Android uses the return stack to manage the activity. In standard mode, every time a new activity is started, it will add the stack to the return stack, and at the top of the stack. The system does not care whether the activity already exists in the returned stack. A new instance of the activity will be created each time it is started.

2. singleTop

When the Startup Mode of the activity is specified as singleTop, if it is found that the stack top of the returned stack is already the activity when the activity is started, it is considered to be used directly and no new active instances will be created. It can solve the problem of repeated stack top creation activities.

3. singleTask

When the active startup mode is specified as singleTask, the system first checks whether the active instance exists in the returned stack each time it starts the activity. If the active instance exists, it is directly used, all the activities above this activity are pushed out of the stack. If no activity is found, a new activity instance is created.

4. singleInstance

The singleInstance mode should be the most special and complex of the four startup modes. Different from the above three startup modes, an activity specified as singleInstance mode enables a new return stack to manage this 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.