Android Things: Raspberry Pi screen timeout

后端 未结 2 1401
温柔的废话
温柔的废话 2020-12-19 21:54

I\'m building app on Raspberry Pi with Android Things and I have 7 inch touch screen, but the screen never turns off.

Is it possible to set timeout

相关标签:
2条回答
  • 2020-12-19 22:21

    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
    
    0 讨论(0)
  • 2020-12-19 22:37

    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.

    0 讨论(0)
提交回复
热议问题