Android's 5 process levels

Source: Internet
Author: User

1, foreground process    is in activity resume status     is in the state of bound service interaction     The state in which the service is running in the foreground (Startforeground () is called)     service life cycle is being executed (onCreate (), OnStart (), OnDestroy ())     Broadcastreceiver is executing the onreceive () method     killing foreground requires a user response because this security priority is the highest     is required for user action, at any time, Only a handful of processes will be in the foreground and will only be killed if the memory is simply not available for them to run at the same time. In general, in this case, the device is still in the state of using virtual memory and must kill some foreground processes to remain responsive in the user interface. Android will measure the level of a process as high as possible based on the importance of the current active component in the process. For example, if a process has both a service and a visual activity, the process is judged to be a visual process, not a service process. 2. Visible process    activity is not displayed on the front, but is not completely hidden, can be seen, such as popup a dialog box     A bound to visible or foreground activity service    No foreground component, but can still be seen by the user on the screen. A process is considered visible when any of the following conditions are met:? It contains an activity that is not in the foreground but is still visible to the user (its OnPause () method is called). This situation may occur if, for example, the foreground activity is a dialog box, and the previous     activity is under it and can be seen. It contains a service that is bound to a visual activity. Visual processes are still considered important and cannot be killed until the foreground process is run without killing them. 3, service process    is running, not in the above two states the services are initiated by the StartService () method, it will not become the above two categories. Although service processes are not directly visible to the user, they are generally doing what the user cares about(such as playing MP3 in the background or downloading something from the Internet). As a result, the system tries to keep them running, unless the system is running out of memory to maintain the foreground and visual processes. 4. Background process    Invisible activity process, onStop is called     contains activity that is not currently visible to the user (OnStop () of the Activity object Method has been called). These processes are not directly linked to the user experience and can be killed at any time to reclaim memory for use by foreground processes, visual processes, and service processes. In general, there are many background processes running, so they are generally stored in an LRU (last-use) list to ensure that the last activity that is used by the user is finally killed. If an activity correctly implements the lifecycle method and captures the correct state, the process that kills it has no adverse effect on the user experience. 5. Empty process    does not run any component processes, this process is reserved primarily for caching needs     does not contain any active application components. The only reason this process exists is to cache to improve the startup time when the component is running again. This process is often killed by the system to maintain a balance between the process cache and the system kernel cache. In addition, the level of a process may be elevated because other processes depend on it. A process level that provides services to other processes is always higher than the process that uses it. For example, if a content provider in a process serves a client in process B, or if the service in process A is bound to a component in process B, the a process is considered to have the same importance as process B.

Android's 5 process levels

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.