Can I change the LED intensity of an Android device?

Buda Gavril picture Buda Gavril · May 11, 2011 · Viewed 40.1k times · Source

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?

Answer

Kevin TeslaCoil picture Kevin TeslaCoil · Aug 5, 2011

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.