The life cycle of an Android app

Source: Internet
Author: User

(1) Front desk (Foreground) process
Closely related to what the user is currently doing, different application components can move its hosting process to the foreground in different ways. You can consider moving the process to the foreground when any of the following conditions are met.
The process is running an activity that interacts with the user (its Onresume () method is invoked) at the front end of the screen;
The process has a running Broadcastreceiver (its broadcastreceiver.onreceive () method is executing);
The process has a service, and there is code in progress within a service's method (Service.oncreate (), Service.onstart (), or Service.ondestroy ()).
(2) Visible process
It has an activity that can be seen by the user from the screen, but not in the foreground-its OnPause () method is called. For example, if the activity in the foreground is a dialog box, the previous activity is hidden behind the dialog box, and this process can occur. Such a process is important and is generally not allowed to be killed unless it is necessary to ensure that the foreground process runs.

(3) Service process
There is a service that has been started with the StartService () method, although these process users cannot see directly, but what they do is the user's concern (for example: background MP3 playback or background network data upload/download). Therefore, the system will run these processes until the memory is insufficient to maintain all foreground processes and visible processes.
(4) Background (Background) session
Having an activity that is not visible to the current user (its OnStop () method is called), these processes have no direct impact on the user experience. If they perform the activity lifecycle correctly, the system can kill the process at any time to reclaim memory and provide it to the previous 3 types of processes. There are usually many such processes running in the system, so keep them in the LRU list to ensure that the last one that the user has seen is killed when the memory is low.
(5) null (empty) process
Does not contain any active application components. The only reason to keep this process is to increase the startup speed by not having to recreate the process the next time a component of the application needs to be run.
The "process" mentioned above is considered from the point of view of the system operation, and various processes can be understood as different state machines for various components of Android. You can focus on the life cycle of the various components of Android, from the application's code and operational considerations.

The life cycle of an Android app

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.