7

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

Praeterii
  • 340
  • 6
  • 16
HardCoder
  • 3,026
  • 6
  • 32
  • 52

3 Answers3

3

If you're developing your own ROM or you have a rooted phone (it's need to be checked which user is able to do this) then you should have a look to the PowerManager.goToSleep functionality. Here is a discussion about this function in the Google Groups. And here you can read about this particular permission.

Community
  • 1
  • 1
Yury
  • 20,618
  • 7
  • 58
  • 86
1

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.

Christian.D
  • 879
  • 1
  • 9
  • 21
1

http://developer.android.com/reference/android/os/PowerManager.html#goToSleep%28long%29

This is what i think you are looking for. Don't forget to include following permission.

android.permission.DEVICE_POWER
Vipul
  • 27,808
  • 7
  • 60
  • 75
  • Welcome to Stack Overflow! Do you know that is a Question & Answer based forum? Do you think yours is an answer? You should provide some examples, or at least specify something more than displaying a constant and a link to an API. – Davide Cannizzo Jan 31 '19 at 17:20