logo
logo
Sign in

Android Process States

avatar
meenati biswal
Android Process States

Processes host applications and applications are made up of components. Within an Android system, the current state of a process is defined by the highest-ranking active component within the application that it hosts. As outlined a process can be in one of the following five states at any given time.

 

Foreground Process 

These processes are assigned to the highest level of priority. At any one time, there are unlikely to be more than one or two foreground processes active and these are usually the last to be terminated by the system. A process must meet one or more of the following criteria to qualify for foreground status:

 

Hosts an activity with which the user is currently interacting. Hosts a Service connected to the activity with which the user is interacting. Hosts a Service that has indicated, via a call to start foreground(), that termination would be disruptive to the user experience. Hosts a Service executing either its onCreate(), onResume() or onStart() callbacks. Hosts a Broadcast Receiver that is currently executing its onReceive() method.

 

Visible Process 

A process containing an activity that is visible to the user but is not the activity with which the user is interacting is classified as a “visible process”. This is typically the case when an activity in the process is visible to the user but another activity, such as a partial screen or dialog, is in the foreground. A process is also eligible for visible status if it hosts a Service that is, itself, bound to a visible or foreground activity. Learn more android app development for beginners

Service Process 

Processes that contain a Service that has already been started and is currently executing. 

 

Background Process 

A process that contains one or more activities that are not currently visible to the user, and does not host a Service that qualifies for Service Process status. Processes that fall into this category are at high risk of termination if additional memory needs to be freed for higher priority processes. Android maintains a dynamic list of background processes, terminating processes in chronological order such that processes that were the least recently in the foreground are killed first. 

 

Empty Process 

Empty processes no longer contain any active applications and are held in memory ready to serve as hosts for newly launched applications. This is somewhat analogous to keeping the doors open and the engine running on a bus in anticipation of passengers arriving. Such processes are considered the lowest priority and are the first to be killed to free up resources.  Android Training 

 

 Inter-Process Dependencies 

The situation about determining the highest priority process is slightly more complex than outlined in the preceding section for the simple reason that processes can often be inter-dependent. As such, when deciding as to the priority of a process, the Android system will also take into consideration whether the process is in some way serving another process of higher priority (for example, a service process acting as the content provider for a foreground process). As a basic rule, the Android documentation states that a process can never be ranked lower than another process that it is currently serving. 

collect
0
avatar
meenati biswal
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more