Android activity launch mode

Source: Internet
Author: User

1. Intent determines the task (activity stack) of the activity)

For the "standard" and "singletop" modes, a task generates an intent. Unless the flag_activity_new_task flag is set in the intent, another task is selected for this activity.

The relative singletask and singleinstance modes mark activity as the root of a task, and they will never select another task.

 

2. Can an activity have multiple instances?
An activity in the "standard" or "singletop" mode can be instantiated multiple times and can belong to multiple tasks. A task can also contain multiple instances of an activity class.

 

3. Does an activity instance allow its task to contain instances of other activity classes?
Activiy of singleinstance is the only activity in its task. Instances of other activities will be assigned to other tasks regardless of whether intent has the flag_activity_new_task flag. Besides this, it is the same as singletask.

 

4. Will a new instance be started to respond to the new intent?
Standard acticity starts a new instance to respond to each new intent request. In singletop mode, if the activity is at the top of the activity stack, its instances will be reused; otherwise, new instances will be generated.

There will never be any extra instance in singletask and singleinstance modes. Singleinstance has only one instance in its stack, so it is in the position of the new intent of the service. However
The singletask task may have multiple activity instances, and the singletask activity is not necessarily at the top. In this case, intent will be lost, however, the task is still stimulated and displayed on the foreground.

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.