Android的 - 关闭硬件钥匙灯 [英] Android - turn off hardware key lights

查看:176
本文介绍了Android的 - 关闭硬件钥匙灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我需要一种方法来关灯的标准Android手机按键(主页,菜单,返回和搜索) - 我怎么能做到这一点编程

Inside my app, I need a way to turn off the lights on the standard Android phone keys (Home, Menu, Back, and Search) - how can I do this programmatically?

推荐答案

据<一href="http://android-dls.com/wiki/index.php?title=Android_FAQ#Q%3a_How_can_I_control_the_keyboard_backlight.3F"

According to this page, the hardware key backlights can be controlled by writing to a specific file in the filesystem with superuser privileges (i.e. phone must be "rooted"):

问:我如何控制键盘   背光?

Q: How can I control the keyboard backlight?

答:背光键盘可   通过控制   / SYS /班/ LED指示灯/键盘背光/亮度。   看来,这是一个简单的开关   控制(呼应0将其关闭,   呼应1或更高版本打开它​​)。   出于某种原因,系统默认   背光控制的东西似乎设置   此为83,但我不知道为什么。一世   似乎无法看到任何区别   间83和任何其它号码。该   文件是可读的任何人,但只   可写的根,所以你需要根   访问手机来操纵它   这种方式。

A: The keyboard backlight can be controlled via /sys/class/leds/keyboard-backlight/brightness. It appears that it's a simple on-off control (echoing '0' turns it off, echoing '1' or higher turns it on). For some reason, the default system backlight control stuff seems to set this to "83", but I don't know why. I can't seem to see any difference between 83 and any other number. The file is readable by anyone, but only writable by root, so you'll need root access to the phone to manipulate it this way.

因此​​,要关闭背光编程,你可以调用的 EXEC()

So to turn off the backlight programmatically, you could invoke exec() on the Runtime like so:

Runtime r = Runtime.getRuntime();
r.exec("echo 0 > /system/class/leds/keyboard-backlight/brightness");

取决于你在做什么,但很可能是明智的检查的exec()的结果之后,看看是否发生了写入错误。

Depends on what you are doing, but would probably be wise to check the result of exec() afterwards to see if a write error occurred.

注意:我测试了我自己的手机,似乎没有作为根本工作。但是,这可能不是每一个电话的情况下,所以你可能有不同的结果。

Note: I tested this on my own phone and it seems to work without acting as root. However, this may not be the case on every phone, so you may have different results.

这篇关于Android的 - 关闭硬件钥匙灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆