How to start a dialog (like alarm dimiss /snooze) that can be clicked without unlocking the screen

 ̄綄美尐妖づ 提交于 2019-11-29 02:14:29

May be this will useful. Implement window flag FLAG_SHOW_WHEN_LOCKED along with FLAG_TURN_SCREEN_ON in public WindowManager.LayoutParams ()

or you can use KeyguardManager class( is deprecated in API 13, but still works) by

public KeyguardManager.KeyguardLock newKeyguardLock (String tag)

Use FLAG_DISMISS_KEYGUARD and/or FLAG_SHOW_WHEN_LOCKED instead; this allows you to seamlessly hide the keyguard as your application moves in and out of the foreground and does not require that any special permissions be requested. Enables you to lock or unlock the keyboard. Get an instance of this class by calling Context.getSystemService(). This class is wrapped by KeyguardManager.


WindowManager.LayoutParams


KeyguardManager


Hope you understand now, however feel free to ask if you need more detailed coding instructions for this problem
Cheers..

Will Yan

you can add flags to current window, like this:

    win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
    | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);

if you don't want it permanent, just clear flags you added when you don't need them, use the method: clearFlags(flags).

if your windows type is setted high enough . You can show your window above lock screen.

WindowsParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!