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.