从服务对话框不显示在棒棒糖当屏幕被锁定(Dialog from service not showin

2019-10-22 22:11发布

我试图从onStartCommand方法服务显示一个对话框

private 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拥有奇巧,当设备被锁定,但它不SamsungS6工作,其中有棒棒糖5.0.2在设备锁定时工作正常。

当设备被锁定对话框不显示棒棒糖的。

Answer 1:

更改TYPE_SYSTEM_ALERT到TYPE_SYSTEM_OVERLAY它应该工作



文章来源: Dialog from service not showing on lollipop when screen is locked