Unable to click the below overlay on Android 12

Viewed 206

I have an App on the play store. This app basically creates an overlay on top of all the apps with some colors, It works perfectly for anything below Android 12. But, since Android 12 it no longer works. I can still interact with my application, but once minimized I no longer can click on anything or change anything at all. I have to restart the device to close the application.

  val params = WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
            else WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                    or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                    or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT
        )

This is how I create the overlay on top. I checked the documentation, but could not find any information. I will be grateful if I can get any help and suggestions to fix this issue.

1 Answers

Set alpha to window manager params, its works for me.

Try below snippet code:

if (Build.VERSION.SDK_INT >= 31) 
{
    params.alpha = 0.8f;
}
Related