0

I would like to start an activity like the one used when an alarm starts ringing and a dialog dismiss appears even when the phone is locked and I am able to click it. I have this code from this site but I don't know how to call it when I extend using broadcastreceiver. It always says

the method getWindow() is undefined type for...

I always seemed to get this error everytime I code, what does that mean.

public void unlockScreen() {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            + WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Tokuchi Toua
  • 175
  • 2
  • 3
  • 12

1 Answers1

2

Register boradcast reciever for SCREEEN_ON intent. As screen gets on your braodcast reciever onRecieve(..) will execute, Start your actitvity with flags as you have written in your post in onRecieve method.

DcodeChef
  • 1,550
  • 13
  • 17