tags:

views:

86

answers:

3

Hey i need to wake my sleeping android device up at a certain time. Any suggestions?

P.S. Wake up: turn display on and maybe unlock phone

A: 

Settling an alarm programatically will wake up the phone(play a sound) and i guess the turn on display would be an option there.

I donot think there would be an exposed API that will unlock the phone automatically.

schar
if anything your activity would come up over the lock screen and once you exited it the lockscreen would be there. Like when you are in a phonecall.
schwiz
A: 

i already tried to use an alarm but the display isnt turned on ... no chance

Coxer
+1  A: 

Best is to use some appropriate combination of these window flags:

http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_DISMISS_KEYGUARD
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_KEEP_SCREEN_ON
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_TURN_SCREEN_ON

If you want to run on older versions of the platform that don't support the desired flag(s), you can directly use wake locks and keyguard locks... but that path is fraught with peril.

hackbod
Do you have any thoughts for the alternative path?
Coxer
The KeyguardManager and PowerManager APIs to directly control them. But it is very tricky to use these... in fact, I would argue that it is impossible to use them perfectly for this kind of stuff. That is one of the reasons the flags were introduced.
hackbod