在 android 9.0 Pie 中无法叠加在其他应用之上

Overlay on top of other apps are not working in android 9.0 Pie

谁能告诉我为什么叠加在 Android 饼图中不起作用?这样做需要任何特殊许可吗? 因为他们实际上并没有贬低任何功能,例如:

WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

仍在工作,工作室在此代码中没有给出任何错误。

This is the way i have used to display a dialog overlay on other apps and this is working good in android pie.

 void showDialog() {
    if (context == null)
        context = getApplicationContext();
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View promptsView = layoutInflater.inflate(R.layout.popup_unlock, null, false);
    Lock9View lock9View = (Lock9View) promptsView.findViewById(R.id.lock_9_view);
    Button forgetPassword = (Button) promptsView.findViewById(R.id.forgetPassword);
    lock9View.setCallBack(new Lock9View.CallBack() {
        @Override
        public void onFinish(String password) {
            if (password.matches(sharedPreference.getPassword(context))) {
                dialog.dismiss();

            } else {
                Toast.makeText(getApplicationContext(), "Wrong Pattern Try Again", Toast.LENGTH_SHORT).show();

            }
        }
    });

    forgetPassword.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(AppCheckServices.this, PasswordRecoveryActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
            dialog.dismiss();
        }
    });

    dialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
    } else {
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
    }


    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
    dialog.setContentView(promptsView);
    dialog.getWindow().setGravity(Gravity.CENTER);

    dialog.setOnKeyListener(new Dialog.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode,
                             KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK
                    && event.getAction() == KeyEvent.ACTION_UP) {
                Intent startMain = new Intent(Intent.ACTION_MAIN);
                startMain.addCategory(Intent.CATEGORY_HOME);
                startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(startMain);
            }
            return true;
        }
    });

    dialog.show();

}