我可以更改 Android 设备的 LED 强度吗?
有没有办法设置我想要的 LED 强度?我知道要打开 LED,我使用:
p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
mycam.setParameters(p);
但此代码只是打开 LED。但有没有办法为LED设置不同的强度以获得更强的光或降低光强度呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
HTC 有一个支持此功能的替代 API,但它仅适用于 HTC Sense 设备,并且从 Gingerbread 开始,他们更改了权限,因此仅适用于他们的 Flashlight 应用程序,不适用于第三方应用程序(除非您使用 root)。
但在 2.2 HTC 设备上,您可以通过将字符串写入
/sys/devices/platform/flashlight.0/leds/flashlight/brightness
来使用它。这控制 LED 是否打开以及它的亮度。最大亮度写“128\n”
,半亮度写“64\n”
。易于从 adb shell 进行测试:最后通过在其中写入
"0\n"
将其关闭。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:And finally turn it off by writing
"0\n"
there.简短的回答是:不。
更长的答案 - 也许在某些使用 undocumenterd 调用/参数的设备上。
支持的闪光灯模式及其含义(和行为)因设备而异。
您最好的选择是查询支持的闪存模式,并希望它们按预期工作。
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.
尝试为相机参数设置不同的闪光模式。
您可以使用 setFlashMode() 方法设置 Flash 模式。
这只是为了相机背光。但如果你想改变整个屏幕的强度。查看示例 此处.
Try to set different Flash Modes available for Camera parameters.
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.
尝试找到这个函数的代码:
相信你看完就会知道这是否可行。
看看
public
,似乎不可能Try to find the code of this function:
I beleive that you will find out if this is possible when you look through it.
Looking at the
public
s, it seems impossible我已经在我的三星 Galaxy S3 Mini 上尝试过了。我没有在其他设备上尝试过。
每当我执行此操作时(当 LED 亮起时):
LED 在 3 个强度级别之间旋转。这没有任何意义,但确实有效。
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):
The LED rotates between 3 levels of intensity. It makes no sense, but it works.
此功能已在运行 Android 13 或更高版本的 Android 设备上正式推出。
Android 文档
示例代码
This feature is officially available on Android devices that are running Android 13 or higher.
Android Doc
Sample Code