I have two applications that both use the camera:
A flashlight app I have developed
The camera app
The flashlight app opens the camera, turns on the flash, and runs in the background. However, if you start the camera app while the flashlight is on, there is an error in the camera app since the camera is already in use by the flashlight app:
Can't obtain device
In the flashlight app, how can I release the camera when another app requests it?
Release it every time onPause is called. Call Camera.release() to release it. This will require you to request it again in onResume().
Related
I have an app widget that is a flashlight.
I turn on and turn off the flash inside a service.
When I turn off the Flash release the camera to be used from other applications.
Now if I have the flash on and open the camera application, the camera app stops because I'm still using the camera in my service.
As I can release the camera automatically or detect when you want to be used from another application?
Note : I am developing for api 16-22
I am working on the app that uses camera and mic in background mode. Obviously, when my app is active other camera apps (like Camera) will not work as the camera is held by my app.
Is there any way to get notified when the other app tries to open camera (if the camera is held by my app)?
I want my app to show some popup or notification when any other app tries to get camera (I think it will be more user-friendly to show some notice then to rely on other app's error messages)
I would like to learn more about how the camera can launch over the secure lock-screen (PIN).
My goal is to have a user select either their default camera app or another camera app (like Google Camera). I would then like to invoke or launch the camera without the user being required to enter their pin code, etc.
I have read that this is possible starting with Android 4.2.
Here is the post:
Launch camera activity over lock screen
Currently in my test build the camera app launches, but the user my first unlock the device.
Any help is appreciated.
Thank you.
I am currently looking into creating a location aware security app whereby the camera is disabled if the phone moves into a designated location. I am now able to disable and enable the camera using the Device Administrator class and calling setCameraDisabled to disable the camera. However, the problem I am encountering now is that if the setCameraDisable method is called when the camera is running, the camera app doesn't close. The camera app would only be disabled on the next launch. As such I am wondering is there is a way for me to kill the camera process before calling the setCameraDisabled method. Thanks in advance.
Try this
android.os.Process.killProcess(android.os.Process.myPid());
In my application I have an activity and a service. The service continously manages some data. In certain cases the service sends a broadcast request to the activity to turn on flashlight.
This works very well. However it does not work when app is minimized (manually or by incomming call). As soon as I bring the app back to the front it starts to work again.
As I observed the log I saw that the service is still running when app is minimized. However since the activity is not present anymore the camera object cannot be accessed to activate the flashlight. But there is no error in the log.
Why is the flashlight not activated? How can the flashlight be activated when the app is minimized?
Only the foreground activity can hold the camera. From the Google documentation:
"If your application does not properly release the camera, all subsequent attempts to access the camera, including those by your own application, will fail and may cause your or other applications to be shut down."
You can try claiming it on the service instead, but I suspect that won't work well. It just really wasn't designed to work this way.