I’m making an app that use the flashlight of the camera.
I open the camera with :
Camera cam = Camera.open();
When I start my app, if another app is already using the camera, I get an error :
java.lang.RuntimeException: Fail to connect to camera service
First, is there any way to still use the camera if it has already been opened by another app ?
If it’s not possible, I would like my app to display a message “Camera already in use” instead of crashing.
In this case, how can I detect if the camera is already opened by another app ?
If the camera is in use by another application I don’t believe there is much you can do until that app releases it one way or another. However you can implement a try-catch block to catch the exception: