Get Exception when showing Alert Dialog from Service.
Following is the code in my Service class: I am trying to show an AlertDialog.
But I get the error: Una
Instead of creating a new transparent activity, Use the SYSTEM_ALERT_WINDOW permission to do this
public void onReceive(Context ctx, Intent intent) {
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popup = inflater.inflate(R.layout.mypopup, null, false);
CustomDialog dialog = new CustomDialog(ctx, popup );
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation;
dialog.show();
}