进入应用程序权限屏幕时,系统覆盖图消失

时间:2018-08-21 18:09:31

标签: android permissions overlay

我使用TYPE_APPLICATION_OVERLAY在应用程序上覆盖一些内容。但是,如果我要查看许可,则覆盖会消失。是否有针对API 26的更好的覆盖类型或更好的解决方案?

编辑: 例如,这里消失了叠加层: enter image description here

编辑2: 覆盖代码:

    int layoutType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_PHONE;
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(layoutType);

    layoutParams.format = PixelFormat.RGBA_8888;
    layoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
    layoutParams.token = getWindow().getDecorView().getRootView().getWindowToken();

    FrameLayout frameLayout = new FrameLayout(this);

    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (windowManager != null) {
        windowManager.addView(frameLayout, layoutParams);
    }

    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (layoutInflater != null) {
        layoutInflater.inflate(R.layout.overlay, frameLayout);
    }

0 个答案:

没有答案