Android application does not completely controls its application life cycle, Its have own Linux process. Android device has limited memory so this process is created for the application when code is needed. Another component (Activity, Services and BroadCastReceiver) in application run and kill as per needed for application. That’s how Android system manages Android Application life cycle by reclaim memory.

Android system has priority for processes to ensure smoother and faster user experience by killing or terminating other processes when low memory.

These process types and its priority are :

1.  Foreground process :

This process is highest processes. In Foreground process user is currently doing or interacting with application components. Its define in following conditions :

  • If Activity is in front of user and user interacting with it. That time Activity is in onResume() state in Activity life cycle.
  • BroadCastReceiver¬† is currently running.
  • Service is executing its one of callback methods : Service.onCreate(), Service.onStart(), or Service.onDestroy()

This processes will kill by Android system last , its very rear chance to kill this process because few only few process are running in Foreground.

2. Visible process :

In Visible process Activity is Visible in screen but in onPasue() state of Activity life cycle. Such a case dialog is front of Activity. So this Process will kill only when Foreground process are required to keep running.

3. Service process :

Which Service has been start by startService() method and doing like playing music , Downloading/Uploading data etc work. That process is not in front of user but its really required for user. So In low memory Android system will recover memory or resource only when Foreground and Visible process have not enough memory.

4. Background process :

If Activity is in onStop() , that time user not interacting with activity.So In this case Android system will kill process as per higher priority of process. That type of many process are running in case system manage LRU and kill processes acrodinally.( LRU : Least Recently Used)

5. Empty process :

Empty process is doesn’t hold any active application components. Its only for improve startup time the next time a component of its application needs to run.

Leave a Reply