Toggling flash modes without restarting camera

208 views
Skip to first unread message

Mohit Shetty

unread,
Sep 6, 2021, 4:50:51 AM9/6/21
to Android CameraX Discussion Group
Is there any way to toggle the flash mode without restarting the camera or perhaps calling cameraProvider.unbindAll and cameraProvider.bindToLifecycle again. I tried manually changing the flash mode from the objects orginally passed to the bind lifecycle method, but nothing it seems to follow the old config, maybe because it's copied and passed to the native APIs.

Thanks in advance.

Scott Nien

unread,
Sep 6, 2021, 9:38:04 PM9/6/21
to Mohit Shetty, Android CameraX Discussion Group
Hi Mohit, 
Please try ImageCapture.setFlashMode.  It allows apps to change flash mode without rebinding again. 

For example, 
val imageCapture = ImageCapture.Builder().build()

cameraProvider.bindToLifecycle(lifecycle, cameraSelector, imageCapture...) 

// When flash option is changed,  call the API to configure . 
imageCapture.setFlashMode(..).  

If this doesn't work, then it is probably a bug. 

Scott

On Mon, Sep 6, 2021 at 4:50 PM Mohit Shetty <shetty...@gmail.com> wrote:
Is there any way to toggle the flash mode without restarting the camera or perhaps calling cameraProvider.unbindAll and cameraProvider.bindToLifecycle again. I tried manually changing the flash mode from the objects orginally passed to the bind lifecycle method, but nothing it seems to follow the old config, maybe because it's copied and passed to the native APIs.

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/57e4fe8a-36e3-48a9-80f8-6858eae787a5n%40android.com.

Mohit Shetty

unread,
Sep 12, 2021, 9:19:15 AM9/12/21
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, Mohit Shetty
Hey Scott,

Sorry for the late reply. It works well now. Thanks a lot for the help.

Regards,
Mohit
Reply all
Reply to author
Forward
0 new messages