How to put Android to standby programmatically?

后端 未结 3 1487
暖寄归人
暖寄归人 2021-01-05 08:17

Is it somehow possible to set Android to standby-mode programmatically ?

3条回答
  •  灰色年华
    2021-01-05 08:41

    This functionality has been removed since API level 21: https://developer.android.com/sdk/api_diff/21/changes/android.os.PowerManager.html

    Like Yury also mentioned, before you were able to call powerManager.goToSleep(time), but you would have needed a rooted device or app would have needed to be signed as a system app to acquire the relevant rights.

提交回复
热议问题