Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android dialog over lock screen [closed]

Tags:

android

I am design a apps about alarm clock.

How can I display a dialog even the phone is locked?

I don't want the phone to be unlock. I just want it to display some text on the phone. User need to unlock the phone by themselves on hand for more information.

It is not necessary to use dialog. All I want is just some text to be display.

Thanks you!

like image 200
user1874453 Avatar asked Dec 26 '22 21:12

user1874453


1 Answers

on your activity, add those flags:

public void onAttachedToWindow() {
    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);
}
like image 66
android developer Avatar answered Dec 28 '22 10:12

android developer