1

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Alex DG
  • 1,859
  • 2
  • 22
  • 34
  • 2
    I'm rather glad applications don't have direct access over other applications like this unless they are either root or system app. – EpicPandaForce Sep 25 '19 at 14:51
  • 2
    Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange network, you've granted a non-revocable right, under the [CC BY-SA 4.0 license](//creativecommons.org/licenses/by-sa/4.0/), for Stack Exchange to distribute that content (i.e. regardless of your future choices). By Stack Exchange policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: [How does deleting work?](//meta.stackexchange.com/q/5221) – Dharman Oct 02 '19 at 15:32

1 Answers1

1

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.

Rohit Chauhan
  • 1,119
  • 1
  • 12
  • 30