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

前端 未结 3 1828
我寻月下人不归
我寻月下人不归 2020-12-16 03:18

I dont want to permanently bypass keyguard, just for that moment .For example when a alarm is raised (eg wake up alarm) i can dismiss /snooze it whithout unlocking screen .I

3条回答
  •  轮回少年
    2020-12-16 04:04

    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).

提交回复
热议问题