I have only minor experience with Android and have the following snippet:
String cameraId = cameraManager.getCameraIdList()[1];
System.out.println(cameraId);
cameraManager.setTorchMode(cameraId, true);
which should turn on the flash on the backside camera (Ideally). This snippet is executed in an onClickListener
. When the cameraManager.setTorchMode(cameraId, true);
gets executed, the app gets minimized (I can see its still running - not crashed) but the flash is not turned on.
I am almost exhausted after experimenting options like adding extra check whether the flash is available and all. The project is set for Jellybean+ versions of Android. The test phone is Lollipop 5.0.2.
I know this question may be a duplicate of : How to open device flashlight in Android N?
But had exhaustively tried every option and desperately need a solution. Thanks in advance.