1、上下文传applicationContent类型的
2、添加dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);的属性
3、添加权限
示例:
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();
}