Android 在Service中弹出对话框
1、在Androidmanifest.xml中插入
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
2、对需要弹出的对话框在调用dialog.show()之前使用以下语句(加粗的语句):
1 Dialog dialog=new Dialog(getApplicationContext(),R.style.Dialog_FullScreen); 2 dialog.setContentView(R.layout.call_phone_layout); 3 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 4 dialog.show();
若在show()之后添加则会报错: