I am trying to create an alarm clock that plays a Youtube video at a certain time. When I use wakelock, it plays the Youtube video behind the locked screen with this code:
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "")
I would like the application to wake up the phone and play the Youtube video in front of the lock screen like the native alarm clock application rings in front of the locked screen.
Does anyone know how to do this? Thanks!
You can create a system overlay and play the video on it. Create a service and add this code:
Dont forget to add
SYSTEM_ALERT_WINDOW
permission inside manifest.EDIT: You can also experiment with
TYPE_SYSTEM_ALERT
andTYPE_SYSTEM_ERROR
instead ofTYPE_SYSTEM_OVERLAY
.