5

I am able to successfully add a dialog to the lock screen on APIs prior to Oreo. It seems like google does not allow the flag TYPE_SYSTEM_ERROR anymore from this API on.

Is there any way to show a dialog on 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);
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61

0 Answers0