Android 懸浮彈窗window dialog
阿新 • • 發佈:2019-02-16
使用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();
}
}