Android Startup Mode

Source: Internet
Author: User

Activity Loading Mode
Standard:
In standard mode, a new instance is generated when startactivity () is called. A new activity instance is generated for each intent startup.
The jump source and target activity are the same taskid

Singletop:
When the activity is set to the loading mode of singletop, if the activity already exists at the top of the stack,
Instead of re-creating, it calls onnewintent. If the activity exists but is not on the top, the activity will be re-created.
The jump source and target activity are the same taskid

Singleinstance:
An independent task is created for an activity set to this mode and the task id is exclusive to it.
The unique activity of its stack, Which is reused every time. Other activities cannot exist in the task.
When a task contains its own instance, it calls its own onnewintent.
Eg: A (taskid = 1)-> B (sinleinstance, taskid = 2) --> C (taskid = 1)
If a calls the finish () method after redirecting to B, the taskid of C is 3.
Taskids of the jump source and target activities must be different

Singletask:
Eg: A (taskid = 1)-> B (singletask, taskid = 1)
The activity set to singletask mode does not always create a new taskid.
When it is not the startup surface of the app, it will be the same as the startup surface taskid.
However, you must pay attention to data loss when setting the non-start plane to this mode.
Because it is very likely that a is a welcome page. After initialization and other time-consuming work is completed, call B and A (finish method)
At this time, when the system recycles the memory and re-enters the program on the home side, the initialized data in a will be lost.
Because a is already in the palace, initialization data is lost.
When a singletask activity is started, if it finds that a task already exists, it first destroys the upper part of the task and then calls its onnewintent function.

 

Activity Status:
Activity:
When an activity is on the top of the stack, it is visible, focused, and user input acceptable. Android tries to maintain its activity status as much as possible, killing other activities to ensure that the current activity has enough resources to use.
When another activity is activated, it will be paused.

Pause:
In many cases, your activity is visible but has no focus. In other words, it is paused. The possible cause is that a transparent or non-full screen activity is activated.
When paused, an activity is regarded as an activity, but user input is not acceptable.
In special cases, Android will kill a paused activity to provide sufficient resources for the activity.
When an activity changes to completely hidden, it changes to stopped. "

Stop:
When an activity is not visible, it is "STOPPED.
This activity will still store all its status and member information in the memory. However, when memory is needed elsewhere, it is most likely to be released.
When an activity is stopped, a very important step is to save the data and the current UI status. Once an activity exits or is disabled, it will become available.

Waiting for use:
After an activity is killed and loaded, it is in the waiting state. To be used, acitivity is removed from the activity stack and needs to be restarted before display and availability.

Intent:
The loading mode of an activity is subject to the interaction control between the flag set in the intent object that starts the activity and the feature value of the activity element in the manifest file.

Flag_activity_reorder_to_front
If the activity has been started, a new activity will not be generated, but the activity instance will be added to the top of the stack.

Flag_activity_new_task

 

Flag_activity_clear_top
Flag_activity_reset_task_if_needed
Flag_activity_single_top

 

Android: taskaffinity

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.