Android Application Priority and Process States

Android Process Types, Priority and Process States

The order in which processes are killed to reclaim resources is determined by the priority of the hosted applications. An applicationís priority is equal to its highest-priority component. Where two applications have the same priority, the process that has been at a lower priority longest will be killed first.

Process priority is also affected by inter-process dependencies; if an application has a dependency on a Service or Content Provider supplied by a second application, the secondary application will have at least as high a priority as the application it supports. Itís important to structure your application correctly to ensure that its priority is appropriate for the work itís doing. If you donít, your application could be killed while itís in the middle of something important. The following list details each of the application explaining how the state is determined by the application components comprising it:

1. Active Processes
Active (foreground) processes are those hosting applications with components currently interacting with the user. These are the processes Android is trying to keep responsive by reclaiming resources. There are generally very few of these processes, and they will be killed only as a last resort. Active processes include:
a) Activities in an active state; that is, they are in the foreground and responding to user events. You will explore Activity states in greater detail later in this chapter.
b) Activities, Services, or Broadcast Receivers that are currently executing an onReceive event handler.
c) Services that are executing an onStart, onCreate, or onDestroy event handler.

2. Visible Processes
Visible, but inactive processes are those hosting "visible" Activities. As the name suggests, visible Activities are visible, but they arenít in the foreground or responding to user events. This happens when an Activity is only partially obscured (by a non-full-screen or transparent Activity). There are generally very few visible processes, and theyíll only be killed in extreme circumstances to allow active processes to continue.

3. Started Service Processes
Processes hosting Services that have been started. Services support ongoing processing that should continue without a visible interface. Because Services donít interact directly with the user, they receive a slightly lower priority than visible Activities. They are still considered to be foreground processes and wonít be killed unless resources are needed for active or visible processes.

4. Background Processes
Processes hosting Activities that arenít visible and that donít have any Services that have been started are considered background processes. There will generally be a large number of background processes that Android will kill using a last-seen-first-killed pattern to obtain resources for foreground processes.

5.Empty Processes
To improve overall system performance, Android often retains applications in memory after they have reached the end of their lifetimes. Android maintains this cache to improve the start-up time of applications when theyíre re-launched. These processes are routinely killed as required


Related Topic What are All Android Phone Native Applications
Android An Open Platform for Mobile Development
Unique Features of Android Development Platform
What is Dalvik Virtual Machine and Its Use
Android API Libraries for Developing Applications

nScraps.com © 2011   Privacy Policy  Terms of Service  Feedback