I am using the CameraX library to take pictures in my Android app, but I would like to keep the flash continuously on while the picture is being taken. I've tried using the setFlashMode(FlashMode.ON)
method of the ImageCapture
class, but the flash only fires for a moment during the capture. There does not seem to be a flash mode setting available like FlashMode.TORCH
or FLASH_TYPE_USE_TORCH_AS_FLASH
that would allow for keeping the flash continuously on. Is there a way to achieve this using the CameraX API?
I figured I'd add a button to turn on the torch and use that instead. Just before taking the picture, I automatically turn it off and use the normal flash. This works because my goal is to enable users to illuminate a target in a dark place before taking the picture.
camera = cameraProvider.bindToLifecycle(... ); if (camera.getCameraInfo().hasFlashUnit()) { camera.getCameraControl().enableTorch(true); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.