Is action confirmation widget possible?

Asked

Viewed 31 times

3

I have to put a Alertdialog to confirm if the user really wants to perform certain action, it is simple to do this in an Activity or Fragment only I’m having problems to do this in the widget, I tried to do but I’m only getting errors as return.

I have the following code:

  AlertDialog alertDialog = new AlertDialog.Builder(LoginActivity.this).create();
            alertDialog.setTitle("Alert");
            alertDialog.setMessage("Alert message to be shown");
            alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alertDialog.show();

Which returns me the following error:

java.lang.Runtimeexception: Unable to start receiver

android.view.Windowmanager$Badtokenexception: Unable to add window -- token null is not for an application

Caused by: android.view.Windowmanager$Badtokenexception: Unable to add window -- token null is not for an application

1 answer

2


I found the solution to my problem to all who have the msm problem here this a solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.