1

My code must automatically turn on the flashlight LED when the light is insufficient.

I can turn the flashlight on in the torch mode:

camera = Camera.open();
final Parameters p = camera.getParameters();
// ...
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);

But I must not turn it on when it is not needed.

How do I find out, programmatically, whether I need to turn the flashlight on?

In other words, how can my application know if there's enough light?

18446744073709551615
  • 16,368
  • 4
  • 94
  • 127

2 Answers2

1

You can look at these two SO posts for checking, what light level is around you:
Lightsensor Value and Brightness of surrounding

But you have to decide, at which light level you'll turn the flashlight on.

Community
  • 1
  • 1
0

If you wish have it turn on automatically while taking a photo if the light is insufficient, then FLASH_MODE_AUTO should do the trick for you

Nyx
  • 2,233
  • 1
  • 12
  • 25