0

I'm writing a service on android and I need to turn off the screen after a certain time, I tried using all solutions on this thread enter link description here

but none of them worked, thus is there any way i can simulate the power button? Thank you

Community
  • 1
  • 1
Xitrum
  • 7,283
  • 25
  • 83
  • 118
  • 1
    you just lock a screen with WAKE_LOCK. – user370305 Nov 17 '11 at 10:46
  • "turn off the screen after a certain time" - means what? you want to lock the screen or dim the brightness of screen? – user370305 Nov 17 '11 at 10:54
  • "I need to turn off the screen after a certain time" -- the user might actually be using their device at that point. Your service has no way to know that. If you are not forcing the screen to stay awake via a `WakeLock`, the screen will go dark of its own accord, sometime after the user stops using the device, based on a user-defined timeout. Please allow the device to behave normally for the user. – CommonsWare Nov 17 '11 at 12:10
  • @user370305 I want to lock and turn off the screen, there is program on the market named Screen Off and Lock, this program allows you to lock the screen and turn off, I just want to do like that :( – Xitrum Nov 17 '11 at 12:13
  • This is achieved by the answer of question link you linked in your question. Just use properly. – user370305 Nov 17 '11 at 12:20
  • @user370305 thanks, let me try it again, the last time i used, it just dims the screen – Xitrum Nov 17 '11 at 12:27

0 Answers0