android 在Application中弹框

   AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
   builder.setMessage("蓝牙出问题了,重启蓝牙试试!!");
   AlertDialog alertDialog = builder.create();
   alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
   alertDialog.show();

1.需要设置type:alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
2.需要在AndroidManifest.xml增加权限:


你可能感兴趣的:(android 在Application中弹框)