使用getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT)设置全局对话框
添加权限
public static void showDialog(String name){
try {
if (dialogPtt != null && dialogPtt.isShowing()) {
return;
}else if (dialogPtt != null && !dialogPtt.isShowing()){
dialogPtt.show();
return;
}
dialogPtt = new Dialog(MyApplication.instance);
View view = LayoutInflater.from(MyApplication.context).inflate(R.layout.dialog_progress, null);
dialogPtt.setContentView(view);
TextView tv_name = (TextView) view.findViewById(R.id.tv_name);
tv_name.setText(name);
dialogPtt.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialogPtt.show();
dialogPtt.setCancelable(false);
}catch (Exception e){
e.printStackTrace();
}
}