37

Is there a way to set the LED intensity that I desire? I know that to turn on the LED I use:

     p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
     mycam.setParameters(p);

But this code just turns on the LED. But is there a way to set different intensities to the LED for a stronger light or to reduce the light intensity?

3
  • I don't think so, but I am not sure. And if so it definitely won't work on all devices. You might also consider removing the [flash] tag since it is for Adobe flash and someone might get here expecting the question to be related to that.
    – FoamyGuy
    May 11, 2011 at 20:31
  • 2
    My HTC Evo comes with a "flashlight" feature that uses the LED "flash", and has three different brightness settings. Works like a champ too. So there must be some way to do it. Since its a built-in app, I suppose it could be device-specific though.
    – T.E.D.
    May 11, 2011 at 20:42
  • hopefully my answer would help you.
    – N-JOY
    Aug 3, 2011 at 5:16

6 Answers 6

27
+25

HTC has an alternative API that supports this, however it's only on HTC Sense devices, and as of Gingerbread they've changed the permissions so it's only for their Flashlight app, not third party ones (unless you use root).

But on 2.2 HTC devices you can use it by writing a string to /sys/devices/platform/flashlight.0/leds/flashlight/brightness. This controls if the LED is on and how bright it is. For maximum brightness write "128\n", half brightness write "64\n". Easy to test from adb shell:

echo "128" > /sys/devices/platform/flashlight.0/leds/flashlight/brightness

And finally turn it off by writing "0\n" there.

7
5

Short answer is: NO.
Longer answer - maybe on some devices using undocumenterd calls / parameters. Supported flash modes, and their meanings (and behaviours) differ from device to device.

Your best option is to query supported flash modes, and hope they work as intented.

4

Try to set different Flash Modes available for Camera parameters.

* FLASH_MODE_OFF
* FLASH_MODE_AUTO
* FLASH_MODE_ON
* FLASH_MODE_RED_EYE
* FLASH_MODE_TORCH

you can set Flash mode using setFlashMode() method.

This was just for camera back light. but if you want to change complete screen intensity. have a look at the example here.

0
2

Try to find the code of this function:

private native final void native_setParameters(String params);

I beleive that you will find out if this is possible when you look through it.

Looking at the publics, it seems impossible

2

I have tried this in my Samsung Galaxy S3 Mini. I have not tried on other devices.

Whenever i do this (while the led is ON):

public void changeIntensity()
{
    cam.stopPreview();
    cam.startPreview();
}

The LED rotates between 3 levels of intensity. It makes no sense, but it works.

0
0

This feature is officially available on Android devices that are running Android 13 or higher.

Android Doc

Sample Code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.