Hi,
I ma trying to switch on the flash light of the camera during the AR session.
I have seen that there is no API for that on com.google.ar.core.Camera
Nevertheless, I was trying to switch it in anyway using Camera2 with the following code:
CameraManager camManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String cameraId = null; // Usually back camera is at 0 position.
try {
cameraId = camManager.getCameraIdList()[0];
camManager.setTorchMode(cameraId, true); //Turn ON
} catch (CameraAccessException e) {
e.printStackTrace();
}
But I get the error:
CameraService: setTorchMode: torch mode of camera 0 is not available because camera is in use
W/System.err: android.hardware.camera2.CameraAccessException: CAMERA_IN_USE (4): setTorchMode:1866: Torch for camera "0" is not available due to an existing camera user
W/System.err: at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:705)
W/System.err: at android.hardware.camera2.CameraManager$CameraManagerGlobal.setTorchMode(CameraManager.java:940)
W/System.err: at android.hardware.camera2.CameraManager.setTorchMode(CameraManager.java:562)
W/System.err: Caused by: android.os.ServiceSpecificException: setTorchMode:1866: Torch for camera "0" is not available due to an existing camera user (code 7)
W/System.err: at android.os.Parcel.readException(Parcel.java:1972)
W/System.err: at android.os.Parcel.readException(Parcel.java:1904)
W/System.err: at android.hardware.ICameraService$Stub$Proxy.setTorchMode(ICameraService.java:547)
W/System.err: at android.hardware.camera2.CameraManager$CameraManagerGlobal.setTorchMode(CameraManager.java:938)
It seems that I get this error because I am trying to access the camera whereas it is already used by ARCore.
Am I doing something wrong ? Am I missing something? Is there a workaround?
Thanks
This is not currently possible.
Duplicate of #153
@inio any update on this?
Any update?
Most helpful comment
@inio any update on this?