Activity Four startup modes and activity Four modes

Source: Internet
Author: User

Activity Four startup modes and activity Four modes

Activity has four startup modes:

1. standard, default startup mode. If Activity is activated, a new instance is created and put into the task stack. In this way, multiple instances of one Activity may exist in the task stack at the same time.

2. singleTop: when the Activity is activated, if the Activity is on the top of the stack, no new instances will be created. if the Activity is not on the top of the stack, a new instance will be created.

3. singleTask: If an Activity instance exists in the stack, the instances of other activities above the stack are removed so that the Activity instance is at the top of the stack. If no instance exists in the stack, create a new instance.

4. singleInstance: one instance where multiple applications share an Activity. whether the Activity is activated or not, the instance is reused.

You can set the Startup Mode for the Activity in AndroidManifest. xml by setting the android: launchMode attribute.

Some applications need to jump back and forth in two forms, such as A --> B, B --> ,......, in this case, you need to set the start mode of A and B to singleTask. Otherwise, when you press the return key, A and B will jump back and forth.

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.