Android - turn off hardware keys

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

+3
source share
2 answers

In accordance with this page , the backlight control of the hardware key can be controlled by writing to a file in the file system with superuser privileges (that is, the phone must be "root"):

Q: How can I control the keyboard backlight?

A: /SYS/ //-/. , - (- "0" , "1" ). - , , "83", . , 83 . , root, root .

, , exec() Runtime, :

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

, , , , exec() , , .

: , , , root. , .

+3
This is applicable only for the device samsung devices:

To get the BackLight sate:
int backLight = Settings.System.getInt(getContentResolver(), "button_key_light");
// if it return -1 it means that light is on
// if it return 0 the light is off
// some time it will return values like 600(1.5 sec)
if you want to put the backLight as off u can do like this

Settings.System.putInt(getApplicationContext().getContentResolver(), "button_key_light", 0);
+1

Source: https://habr.com/ru/post/1774234/


All Articles