Nowadays how does it work to kill the camera process in the background?
I tried a couple of solutions:
val pid = Process.getUidForName("camera")
Process.killProcess(pid)
or
activityManager.killBackgroundProcesses("com.android.camera");
I'm also using the kill background process permission in my Manifest: android.permission.KILL_BACKGROUND_PROCESSES
I also tried to figure out how I could get all the background processes running with activityManger.runningAppProcesses
but this code only return an array with my current active app, I can't see the camera or anything else.
Although with the PackageManager
I managed to get all app installed on the phone and check if they are flagged has "stopped" or not so I can filter which one is running or not. But still the Process.killprocess
is not working. I guess I'm missing some permissions to make it work.
You can not do it with the regular app, and one thing you can do it try implementing the device manager. you can use DeviceAdministration class to control the camera source(block and unblock). Check out this Github repo with an example.