문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top