我可以更改 Android 设备的 LED 强度吗?

发布于 2024-11-06 05:33:13 字数 207 浏览 2 评论 0原文

有没有办法设置我想要的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

苦妄 2024-11-13 05:33:13

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 进行测试:

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

最后通过在其中写入 "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:

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

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

孤凫 2024-11-13 05:33:13

简短的回答是:不。
更长的答案 - 也许在某些使用 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.

一笑百媚生 2024-11-13 05:33:13

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

* FLASH_MODE_OFF
* FLASH_MODE_AUTO
* FLASH_MODE_ON
* FLASH_MODE_RED_EYE
* FLASH_MODE_TORCH

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

这只是为了相机背光。但如果你想改变整个屏幕的强度。查看示例 此处.

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.

匿名的好友 2024-11-13 05:33:13

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

private native final void native_setParameters(String params);

相信你看完就会知道这是否可行。

看看public,似乎不可能

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

〃温暖了心ぐ 2024-11-13 05:33:13

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

每当我执行此操作时(当 LED 亮起时):

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

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):

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

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

败给现实 2024-11-13 05:33:13

此功能已在运行 Android 13 或更高版本的 Android 设备上正式推出。

Android 文档

示例代码

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

Android Doc

Sample Code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文