在服务启动对话框不依赖Activity
Builder builder=new Builder(getApplicationContext());
builder.setTitle("Title");
builder.setMessage("This is message");
builder.setNegativeButton("OK",null);
Dialog dialog=builder.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show();
权限
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
builder.setTitle("Title");
builder.setMessage("This is message");
builder.setNegativeButton("OK",null);
Dialog dialog=builder.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show();
权限
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>