I can successfully add a dialog to the API lock screen before Oreo. It seems that google doesn't allow the flag TYPE_SYSTEM_ERROR
anymore from this API.
Is there a way to show the dialogue on the lock screen on Android O?
Code that works for <Android O
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DIM_BEHIND;
int type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
0,
0,
type,
flags,
PixelFormat.RGBA_8888);
source
share