Android Interview Collection catalog Android process priority

Source: Internet
Author: User

In Android: When the system is running low on memory, the Android system will kill some less important processes based on the priority of the process, and the lower priority kills first. The process priority is from high to low as follows.

Foreground process
    • In the activity that is interacting with the user
    • Service bound to the foreground activity
    • Service that called the Startforeground () method
    • Executing service for OnCreate (), OnStart (), OnDestroy method.
    • The process contains the broadcastreceiver that is executing the onreceive () method.

There are not many foreground processes in the system, and generally the foreground process is not killed because of insufficient memory. Except in special cases. Killing a process is not an option when memory is low to ensure that all foreground processes are running at the same time.

Visual process
    • Activity that is in the foreground but still visible (for example, call OnPause () and not yet call OnStop (). Typically, when you run the activity, the dialog box pops up (dialog, etc.), but the activity is still visible, although it is not the foreground activity.
    • The service to which activity is bound is visible. (Service bound by activity in case of appeal)

The visual process is generally not killed by the system unless it is necessary to ensure that the foreground process is running.

Service process
    • Service that has been started

Background process
    • Invisible activity (activity after calling OnStop ())

The background process does not affect the user's experience, in order to ensure that the foreground process, visual process, the running of the service process, the system may at any time kill a background process. When a properly implemented lifecycle activity is killed in the background, the previous run state is restored if the user restarts.

Empty process
    • Any process that is not active

The system kills empty processes, but this does not affect them. The existence of an empty process is nothing more than a cache, so that it can be started faster next time.

Reference articles

Https://github.com/LRH1993/android_interview/blob/master/android/basis/process-priority.md

Android Interview Collection catalog Android process priority

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.