1

I use this code to show the overlay layout in my app. In android 8.0 "Oreo" it crashes

WindowManager.LayoutParams playerParams = new WindowManager.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
        WindowManager.LayoutParams.FLAG_FULLSCREEN,
        PixelFormat.TRANSLUCENT);

I found that this TYPE_SYSTEM_ERROR is deprecated in O. Is there any other way to show the layout.

Jijith J
  • 173
  • 2
  • 12

1 Answers1

3

I was also facing the same issue the TYPE_SYSTEM_ERROR is Deprecated in oreo So if we have to use that we need to do this

WindowManager.LayoutParams params;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            PixelFormat.TRANSLUCENT);
} else {
    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            PixelFormat.TRANSLUCENT);
}

You can try this out.

Amjad Khan
  • 1,309
  • 15
  • 32