Right now, I'm using the following permission to show a dialog over another app :
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Dialog :
dialogBuilder = new AlertDialog.Builder(activity);
LayoutInflater inflater2 = (LayoutInflater) AppController.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater2.inflate(R.layout.dialog_view, null);
dialogBuilder.setView(dialogView);
dialog = dialogBuilder.create();
dialog.setCancelable(true);
final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
final Window dialogWindow = dialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setAttributes(layoutParams);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
dialogWindow.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
} else {
dialogWindow.setType(WindowManager.LayoutParams.TYPE_PHONE);
}
}
dialog.show();
Snaptube app, shows a dialog over the YouTube app without asking for any permission :

How I can achieve that?