Android Things: Raspberry Pi screen timeout

百般思念 提交于 2019-11-29 11:54:49

There are two system settings that control this process: STAY_ON_WHILE_PLUGGED_IN and SCREEN_OFF_TIMEOUT

The STAY_ON_WHILE_PLUGGED_IN setting is set to BATTERY_PLUGGED_AC by default. You can programmatically change this value in your application code with the Settings API:

Settings.Global.putInt(getContentResolver(),
        Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);

You can also make this change from the command line if it is more convenient:

$ adb shell settings put global stay_on_while_plugged_in 0

The approach below works starting with Android Things Developer Preview 5.0. For older releases it has no effect.

Turn off display:

adb shell settings put global stay_on_while_plugged_in 0

Turn on display:

adb shell settings put global stay_on_while_plugged_in 1
adb shell input keyevent 26

For a programmatic solution see @Devunwired's answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!