我试图在onStartCommand方法
中显示来自服务的Dialogprivate Dialog incomingCallDialog;
incomingCallDialog = new Dialog(MyService.this, R.style.PopupDialog);
incomingCallDialog.setCancelable(false);
incomingCallDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
incomingCallDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
incomingCallDialog.setContentView(view);
Handler delayHandler = new Handler();
delayHandler.postDelayed(new Runnable() {
@Override
public void run() {
incomingCallDialog.show();
}
}, 100);
此代码在SamsungS5中运行正常,它有Kitkat,当设备被锁定但在设备被锁定时在带有棒棒糖5.0.2的SamsungS6上不起作用。
当设备锁定时,Lollipop中根本不显示对话框。
答案 0 :(得分:1)
将TYPE_SYSTEM_ALERT更改为TYPE_SYSTEM_OVERLAY它应该工作