使android的dialog全局显示

1、上下文传applicationContent类型的

2、添加dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);的属性

3、添加权限"android.permission.SYSTEM_ALERT_WINDOW" /> 

示例:

	AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());  
                  AlertDialog dialog=builder.setMessage("领取奖励")  
                          .setPositiveButton("确定",new DialogInterface.OnClickListener(){  
                              @Override  
                              public void onClick(DialogInterface dialogInterface, int i) {  
                              }  
                          }).create();  
                  dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);  
                  dialog.setCanceledOnTouchOutside(false);
                  if (!dialog.isShowing()){
                      dialog.show();  
                  }  


你可能感兴趣的:(使android的dialog全局显示)