Four types of Launchmode activity in Android development

Source: Internet
Author: User

Activity stacks are primarily used to manage the switching of activity. When using intent to jump to a target activity, it needs to be loaded according to the load mode of the target activity.

The activity has the following four kinds of Launchmode:

1.standard: By default, a new instance is created each time you use intent to jump to the target activity. The downside is that every time you enter, you create a new instance and execute the OnCreate method.

2.singleTop: If the target activity to jump is exactly at the top of the task (indicating that it is not currently in the target task, for example, I am on the home page, and then want to use intent to jump to the Innoxyz app's homepage, Then join the INNOXYZ home right at the top of the INNOXYZ task, just jump in instead of creating an instance, then jump directly past without creating a new. (example, currently in home screen, received a push of the home page, and the task stack in the task in the activity stack of the top is exactly the first page, then click the push directly into the instance without creating a new instance)

3.singleTask: this instance will be generated in a new task, which will be used for each invocation, and will not produce a new instance.

4.singleInstance: Is the only activity on its stack, which is reused every time.

Launchmode plays an important role in the process of multiple activity jumps, it can decide whether to generate new activity instances, whether to reuse existing activity instances, and whether to share a task with other activity instances. Here is a brief introduction to the concept of a task, which is an object with a stack structure, a task that can manage multiple activity, launch an application, and create a corresponding task.

We can configure <activity> the Android:launchmode attribute in Androidmanifest.xml for one of the above four kinds.

android:exported
    1. In activity, this attribute is used to indicate whether the current activity can be started by another application component: True allows it to be started, and false does not allow it to be started.

    2. Android:exported is one of the four components of Android Activity,service,provider,receiver a property in all four components.

    3. Overall its main role is to support other applications to invoke the current component.

Four types of Launchmode activity in Android development

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.