How to Disable Keyguard and display an activity to the user when receiver of SCREEN_ON is triggered?

后端 未结 3 937
滥情空心
滥情空心 2020-12-29 00:33

How can I disable the keyguard when a broadcast receiver is activated by screen_on, so that when it occurs the user sees an activity that I have started behind it? (The act

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 01:03

    I'm not seeing the Keyguard solution work (and it's been deprecated). What works for me is to grab a permanant PARTIAL_WAKE_LOCK that I never release. This prevents the device from truly falling asleep and thus avoids the lock-screen every being activated.

    Then every time the screen shuts off, I listen for that notification and wake the device back up. It works on all the devices I have tested on.

    I realize that this will kill the device's battery pretty fast, so, you have to use this very sparingly and mindfully.

提交回复
热议问题