我正在为我的应用程序构建一个覆盖 UI。用户界面接受输入并在 android 上按预期工作<= 12 but on android 13 it becomes unresponsive. The exact same code/build works on Android 12 but not on 13. This is the code using which I am creating the overlay:-
View test = LayoutInflater.from(context).inflate(R.layout.test, null, false);
WindowManager.LayoutParams params =
new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.OPAQUE);
windowManager.addView(test, params);
我已确保该应用程序具有“绘制其他应用程序”权限。
android 13 行为变化page 也没有提及 APPLICATION_OVERLAY 的任何内容。
尝试这些标志组合:
new WindowManager.LayoutParams(
width,
height,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);