0

I have issues with torch on Lenovo Android A536, where setFlashMode is ignored:

    Camera.Parameters parameters = camera.getParameters();
    Log.i("Scanner/Light", parameters.getFlashMode() + " " + context.isLight());

    if (context.isLight()) {
        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
        camera.setParameters(parameters);
        menu.getItem(0).setIcon(R.drawable.ic_flash_on);
        Log.i("Scanner/Light", "Flash on.");
    } else {
        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
        camera.setParameters(parameters);
        menu.getItem(0).setIcon(R.drawable.ic_flash_off);
        Log.i("Scanner/Light", "Flash off.");
    }

    parameters = camera.getParameters();
    Log.i("Scanner/Light", "Final: " + parameters.getFlashMode());

From logs I can see, that the light is properly turned on/off, however the LED tend to stay in previous state. Even when I see the log Final in state off, the physical light sometimes stays in state torch and vice versa. This does not happen on any other device we have.

Vojtěch
  • 11,312
  • 31
  • 103
  • 173
  • I recommend you to use `getSupportedFlashModes` before set the parameter. would you check the link http://stackoverflow.com/a/23337134 ? – Youngjae Oct 23 '15 at 08:08
  • I can confirm that on each call, FlashMode.TORCH is supported. As I stated, it works, but randomly. – Vojtěch Oct 23 '15 at 09:13

0 Answers0