Question

I have written a simple code which should blink the camera flash of a Android device with 500ms pause. But someways it is nothing doing ...

public void flicker_500ms (){
    int intern_i;
    final Parameters p = camera.getParameters();
    for (intern_i = 0;intern_i == 100;++intern_i){
        p.setFlashMode(Parameters.FLASH_MODE_OFF);
        camera.setParameters(p);
        camera.stopPreview();
        isLighOn = false;
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                p.setFlashMode(Parameters.FLASH_MODE_TORCH);
                camera.setParameters(p);
                camera.startPreview();
                isLighOn = true;
            }
        }, 500);
    }
}

Someone got a why this Code is not working ? Or maybe a alternative ?

Thanks !

Était-ce utile?

La solution

Because your condition is failed in your for loop so your code is not executing once

for (intern_i = 0;intern_i == 100;++intern_i)
                           ^^

I think you want like this or set your condition as per yourself

for (intern_i = 0;intern_i <= 100;++intern_i)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top