1

I want to enable/disable camera programmatically in my application.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Girija Patil
  • 430
  • 1
  • 5
  • 16

3 Answers3

4

You cannot do this from a regular app. You can do it from a device administrator, but the user has to explicitly enable it and it is only available on ICS. Here's the reference: http://developer.android.com/guide/topics/admin/device-admin.html

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
3

The OP is asking for any ideas, I got one idea and it could possibly work even without using the API provided by ICS.

for lower API version than ICS, you can Start a service that will lock the Camera when the screen is On and Release it when the Screen is Off. This is to minimize the usage of battery.

Since, only one process can use the Camera at a time, other applications like the Camera App will not be able to use the Camera.

The challenge now is how to ensure that the Service Hogging the Camera is always Running and prevent it from being uninstalled by the user.

Well, just a thought ;)

Macchiato
  • 825
  • 1
  • 11
  • 24
1

Yes, you can use DeviceAdministration class and control the camera source(block and unblock). This is a repo with an example.

Mario Alzate
  • 372
  • 3
  • 8