I am trying to show a Dialog from service in onStartCommand method
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);
This code works fine in SamsungS5 which has Kitkat and when device is locked but it doesn't work on SamsungS6 which has lollipop 5.0.2 when device is locked.
The dialog is not showing at all in Lollipop when device is locked.