Activity start mode and activity start Mode

Source: Internet
Author: User

Activity start mode and activity start Mode
Activity can be started in four modes: standard, singleTop, singleTask, and singleInstance. Android manages Activity instances in the stack rollback mode. Stack is a collection of advanced and backward outputs. For example, if we open an Activity, the current display is at the top of the stack. When the user clicks back or the return button of the application, the system will output the Activity at the top of the stack, then the next Activity at the top of the original stack will change to the top of the stack and be displayed on the device. Standard default mode. You do not need to write configurations. In this mode, a new instance is created by default. Therefore, in this mode, you can have multiple identical instances and multiple identical activities. That is to say, multiple activities can exist in the same task stack. For example, if ActivityA already exists and ActivityA calls its startActivity () to start a new ActivityA, there are two ActivityA. SingleTop can have multiple instances, but does not allow the superposition of multiple identical activities. That is, if an Activity starts the same Activity at the top of the stack, it will not create a new instance, but reuse the Activity at the top of the stack and call its onNewIntent method. Singletop mode. If a new instance is started and is not at the top of the stack, a new instance will be created again, and its behavior will be the same as that in standard mode. SingleTask has only one instance. If the Activity does not exist when you start the Activity in the same application, a new instance is created in the current task. If the Activity exists, the destory of other activities in the task is deleted and its onNewIntent method is called. If you start it in another application, a new task is created and the Activity is started in the task. singleTask allows other activities to coexist with it in a task. That is, if I open a new Activity in this singleTask instance, the new Activity will still be in the task of the singleTask instance. SingleInstance has only one instance, and this instance runs independently in one task. This task has only one instance, and other activities are not allowed to exist. When this Activity is started again, existing tasks and instances are reused. Different from singleInstance, singletask has only one instance in a task. singleinstance can only have one instance in the system. singletask can have multiple instances in different tasks.

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.