May 7, 2024 Replies: 2 For some reason there is no support for the torch feature in CamEx2. Add this Sub to CamEx2 (v1.31) to have a torch: B4X: Copy Public Sub setTorch(pbolOn As Boolean, pbolVideoRecording As Boolean) SetBothMaps("FLASH_MODE", FLASH_MODE.IndexOf(IIf(pbolOn, "TORCH", "OFF"))) StartPreview(TaskIndex, pbolVideoRecording) End Sub Click to expand...
For some reason there is no support for the torch feature in CamEx2. Add this Sub to CamEx2 (v1.31) to have a torch: B4X: Copy Public Sub setTorch(pbolOn As Boolean, pbolVideoRecording As Boolean) SetBothMaps("FLASH_MODE", FLASH_MODE.IndexOf(IIf(pbolOn, "TORCH", "OFF"))) StartPreview(TaskIndex, pbolVideoRecording) End Sub
b4x-de Active Member Licensed User Longtime User May 13, 2024 #2 My code above works on old Samsung and Huawei devices but not on modern devices like VIVO with Android 14. The following problem occurs: The torch is turned off immediately before the photo is taken and does not turn on again. I found the Camera.AbortCaptures in the Sub TakePictureNow() responsible for this behavior, but I do not understand why. Can someone please provide more insight into this? Thanks! Btw: It does not help to set the AE Mode to "ON" before setting the Flash to "TORCH" although this can be found in some posts in Stackoverflow as a solution. Last edited: May 14, 2024
My code above works on old Samsung and Huawei devices but not on modern devices like VIVO with Android 14. The following problem occurs: The torch is turned off immediately before the photo is taken and does not turn on again. I found the Camera.AbortCaptures in the Sub TakePictureNow() responsible for this behavior, but I do not understand why. Can someone please provide more insight into this? Thanks! Btw: It does not help to set the AE Mode to "ON" before setting the Flash to "TORCH" although this can be found in some posts in Stackoverflow as a solution.
M Markos Well-Known Member Licensed User Longtime User Dec 1, 2025 #3 b4x-de said: My code above works on old Samsung and Huawei devices but not on modern devices like VIVO with Android 14. The following problem occurs: The torch is turned off immediately before the photo is taken and does not turn on again. I found the Camera.AbortCaptures in the Sub TakePictureNow() responsible for this behavior, but I do not understand why. Can someone please provide more insight into this? Thanks! Btw: It does not help to set the AE Mode to "ON" before setting the Flash to "TORCH" although this can be found in some posts in Stackoverflow as a solution. Click to expand... I dunno if you still have this issue but I found a way to get the flash to work setting the following : Code: Copy setSceneMode("ACTION") SetBothMaps("CONTROL_AE_MODE", AE_MODE.IndexOf("ON")) And to disable flash from always flashing after taking a snapshot Code: Copy setSceneMode("PORTRAIT") SetBothMaps("CONTROL_AE_MODE", AE_MODE.IndexOf("ON_AUTO_FLASH")) The disabling of flash may only need the 1st line but havent had the desire to verify
b4x-de said: My code above works on old Samsung and Huawei devices but not on modern devices like VIVO with Android 14. The following problem occurs: The torch is turned off immediately before the photo is taken and does not turn on again. I found the Camera.AbortCaptures in the Sub TakePictureNow() responsible for this behavior, but I do not understand why. Can someone please provide more insight into this? Thanks! Btw: It does not help to set the AE Mode to "ON" before setting the Flash to "TORCH" although this can be found in some posts in Stackoverflow as a solution. Click to expand... I dunno if you still have this issue but I found a way to get the flash to work setting the following : Code: Copy setSceneMode("ACTION") SetBothMaps("CONTROL_AE_MODE", AE_MODE.IndexOf("ON")) And to disable flash from always flashing after taking a snapshot Code: Copy setSceneMode("PORTRAIT") SetBothMaps("CONTROL_AE_MODE", AE_MODE.IndexOf("ON_AUTO_FLASH")) The disabling of flash may only need the 1st line but havent had the desire to verify