Search code examples
androidcameraandroid-camera

How is Android Camera Client Priority Set?


The camera API docs say that "Active camera clients for lower priority apps may be “evicted” when a higher priority application attempts to use the camera"

My question is, how does an application's priority get set? Is is possible to set this programmatically or at a system level for pre-installed apps?


Solution

  • Android platform sets the priority. For instance, processes running on the foreground have higher priority than services running in the background. The same priority system is used when the device memory is filling up and Android needs to release memory. Lower priority processes get killed.

    You can find the different levels of priority in this API

    https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html

    importance added in API level 3

    int importance

    The relative importance level that the system places on this process. These constants are numbered so that "more important" values are always smaller than "less important" values.

    Value is IMPORTANCE_FOREGROUND, IMPORTANCE_FOREGROUND_SERVICE, IMPORTANCE_TOP_SLEEPING, IMPORTANCE_VISIBLE, IMPORTANCE_PERCEPTIBLE, IMPORTANCE_SERVICE, IMPORTANCE_CACHED or IMPORTANCE_GONE.