Blocking screen interaction is difficult. Android allows you to perform basic operations using two window flags (FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD). FLAG_SHOW_WHEN_LOCKED works quite consistently, because it will be displayed on top of the lock screen even when security is turned on (security is not bypassed, you cannot switch to a different window than FLAG_SHOW_WHEN_LOCKED).
If you just do something temporary, like when music is playing or something like that, you will probably be mostly fine. If you are trying to create a custom lock screen, then there are a lot of unusual interactions on all different Android platforms. ("Help! I cannot turn off the alarm without restarting my HTC phone.").
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html
FLAG_SHOW_WHEN_LOCKED
Window flag: a special flag so that windows are displayed when the screen is locked.
FLAG_DISMISS_KEYGUARD
Window flag: if you install a window, this will cause the keyguard to be rejected only if it is not safe to lock the keypad. Because such a key lock is not required for security. never appear if the user moves to another window (unlike FLAG_SHOW_WHEN_LOCKED, which will temporarily hide both safe and unprotected keyboard locks, but appear when the user switches to another user interface that does not hide them). If a key lock is currently active (an unlock pattern is required) than the user will still need to confirm this before viewing this window if FLAG_SHOW_WHEN_LOCKED has also been set. Constant value: 4194304 (0x00400000)
Kevin TeslaCoil Jan 12 2018-11-12T00: 00Z
source share