Using FlashLight in appWidget and crashes when start app camera - android

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

Related

Get noticed when other app tries to access camera on Android

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)

Camera capture button in Android

I'm using hardware.Camera component in my application but there is a capture button missing. Is it possible to use default capture button, the same as when we start camera as activity from Intent?
There is no "default capture button". When "we start camera as activity from Intent", the activity that appears will be one from hundreds, if not thousands, of available camera apps. This includes both apps pre-installed on Android devices and apps that are installed by users.

Launch Google Camera or Default Camera over lock screen

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.

How can I release the camera when another application requests it?

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().

Kill Camera App Programmatically on Android

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());

Categories

Resources