37

有没有办法设置我想要的 LED 强度?我知道要打开我使用的 LED:

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

但是这段代码只是打开了 LED。但是有没有办法为 LED 设置不同的强度以获得更强的光或降低光强度?

4

5 回答 5

26

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.

于 2011-08-05T16:32:28.893 回答
5

简短的回答是:不。
更长的答案 - 可能在某些使用 undocumenterd 调用/参数的设备上。支持的闪光模式及其含义(和行为)因设备而异。

您最好的选择是查询支持的闪存模式,并希望它们按预期工作。

于 2011-08-05T11:02:36.247 回答
4

尝试为相机参数设置不同的闪光模式。

* FLASH_MODE_OFF
* FLASH_MODE_AUTO
* FLASH_MODE_ON
* FLASH_MODE_RED_EYE
* FLASH_MODE_TORCH

您可以使用 setFlashMode() 方法设置 Flash 模式。

这只是用于相机背光。但如果你想改变完整的屏幕强度。看看这里的例子。

于 2011-08-02T07:11:05.993 回答
2

我已经在我的三星 Galaxy S3 Mini 中尝试过。我没有在其他设备上尝试过。

每当我这样做时(当 LED 亮起时):

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

LED 在 3 个强度级别之间旋转。这没有任何意义,但它有效。

于 2013-12-06T10:31:40.330 回答
2

试着找到这个函数的代码:

private native final void native_setParameters(String params);

我相信当你看透它时你会发现这是否可能。

看着publics,似乎不可能

于 2011-08-05T09:03:30.487 回答