Android Activity Learning little Memory

Source: Internet
Author: User

I. life cycle of activities

1, Android is the use of tasks to manage activities, a task is a set of activities stored in the stack, this stack is also known as the return stack.

2. Activity status

① Run state: When the activity is at the top of the stack at the return stack.

② paused state: The activity is no longer in the top position of the stack, but is still visible.

③ Stop state: The activity is no longer in the top position of the stack and is completely invisible.

④ destroy state: After the activity has been removed from the return stack.

3. The lifetime of the activity

① full lifetime: The activity between the OnCreate () and the OnDestroy () method is the complete survival period.

② visible Lifetime: The activity between the onstart () and the OnStop () method is the visible lifetime.

③ foreground lifetime: Activity between the Onresume () and the OnPause () method, is the foreground lifetime.

Second, the activity of the starting mode --standard, Singletop, Singletask and SingleInstance.

1, Standard mode: is the default startup mode of the activity, without explicit designation, all activities will automatically use this startup mode. For activities that use standard mode, the system does not care if the activity is already present in the return stack, and a new instance of the activity is created each time it is started.

2. Singletop mode: When the specified startup mode of the activity is singletop, if it is found that the stack top of the return stack is already the activity at the start of the activity, it is considered that it can be used directly and no new activity instance will be created.

3, Singletask mode: When the activity's specified startup mode is Singletask, each time the activity is started, the system will first check the return stack for the existence of an instance of the activity, if the discovery already exists then directly use the activity's instance, and put all the activities above the activity out of the stack, If no discovery is found, a new activity instance is created.

4. SingleInstance mode: When the specified startup mode for the activity is singleinstance, a new return stack is enabled to manage the activity.

Android Activity Learning little Memory

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.