I am making an Android hybrid application in which my requirements are that as soon as a notification arrives, my app should open and disable all locks. I tried using KeyguardManager(deprecated)
but it's working on some devices only. Basically below Lollipop only.
Now I am using this piece of code to achieve the desired result but all in vain.
I have seen many posts regarding the same issue everywhere. FLAG_DISMISS_KEYGUARD
is suggested as a replacement for KeyguardManager
,
but this is not working for me.
((Activity) mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);