在Android中使用电容式按钮

时间:2012-09-19 11:16:03

标签: android

我很好奇是否有任何库可以使用三星手机的电容按钮? 我的意思是在事件发生时点亮它们,或者眨眼它们,这样的东西......

谢谢, rohitkg

2 个答案:

答案 0 :(得分:1)

Android SDK中没有任何内容,因为没有假设存在这样的按钮,有背光等。欢迎您联系设备制造商,看看他们是否有记录和支持的方式为他们做这个特定设备。

答案 1 :(得分:0)

这是我从samsung-moment-notifications抓取的代码段。

Process process = null;
DataOutputStream os = null;
try {
    // get root 
    process = Runtime.getRuntime().exec("su");
    os = new DataOutputStream(process.getOutputStream());
    // write the command
    os.writeBytes("echo 100 > /sys/class/leds/button-backlight/brightness\n");
    os.writeBytes("exit\n");
    // clear the buffer
    os.flush();
    Toast.makeText(NotificationLights.this, "Lights are on", Toast.LENGTH_SHORT).show();
    // wait for complete
    process.waitFor();

     // won't catch an error with root, but it has to have an exception catcher to execute
 } catch (Exception e) {
     Toast.makeText(NotificationLights.this, "Couldn't get SU, are you rooted?", Toast.LENGTH_SHORT).show();
       return;
 }

1-您必须拥有root设备。

2-您必须知道脚本的位置,以便为每个设备打开/关闭指示灯。

/sys/class/leds/button-backlight/brightness特定于 Samsung Moment

如果您要在其他设备上试用它,它将无效。