Android Example Turn your camera flash light into a torch - also with Java code inside the B4A project

dragonguy

Active Member
Licensed User
Longtime User
i found the solution, i share here
B4X:
NativeMe.RunMethod("blink",Array(50,50,10))

B4X:
public void blink (int onValue,int offValue,int flashTime){
    m_Camera = Camera.open();
    cameraParameters = m_Camera.getParameters();
   
    for (int i = 0; i <= flashTime; i++) {
        cameraParameters.setFlashMode(Parameters.FLASH_MODE_ON);
        cameraParameters.setFocusMode(Parameters.FOCUS_MODE_INFINITY);
        cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
        m_Camera.setParameters(cameraParameters);
        m_Camera.startPreview();
        try{
            Thread.sleep(onValue);
            }catch(InterruptedException e){
                e.printStackTrace();
                }
        cameraParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
        m_Camera.setParameters(cameraParameters);
        m_Camera.stopPreview();
        try{
            Thread.sleep(offValue);
            }catch(InterruptedException e){
                e.printStackTrace();
                }
    }
    m_Camera.stopPreview();
    m_Camera.release();
    m_Camera = null;
}
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hello to all
I'm trying to use your library with an app that uses cameraex. When I turn on the torch, the image display is blocked and does not resume even if I turn off the torch.

Am I wrong about something or are they incompatible?
 

mahyara

Member
Hi I'm very novice so this maybe very ridiculous I have installed this file but it does not turn on flash neither in Morse mode nor in Torch mode, the logger write dih dah ... and the vibration works perfect. I have this problem with a Sony XPERIA XZ and I have downloaded several torch and stroboscope apps from play store but some of them work and others do not turn on the flash and unfortunately none of the libraries and projects here which try to turn on the flash cannot turn on my phones flash. do you know what maybe the problem?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…