I have implemented a custom camera that records video using the camera2 API. It is possible to set the flash to βOnβ, βoffβ and βAutoβ. Setting the flash to βAutoβ does not work , while other settings work fine.
Here is the code:
private void updateFlash() { Log.e(TAG, "Flash = " + currentFlash); switch (currentFlash) { case Constants.FLASH_OFF: previewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF); break; case Constants.FLASH_ON: previewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH); break; case Constants.FLASH_TORCH: previewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH); break; case Constants.FLASH_AUTO: previewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH); break; } cameraCaptureSession.setRepeatingRequest(previewRequestBuilder.build(), null, null); }
I have a lot of googled and almost all answers on stackoverflow for automatic flash, but no one worked.
Please, help. I do not understand what the problem is.
android camera android-camera2
iMDroid
source share