Widget action confirmation is possible?

2

I have to put an AlertDialog to confirm that the user wants to perform a certain action, it is simple to do this in an activity or fragment, but I am having trouble doing this in the widget, I tried to do but I am only getting errors as a return. / p>

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();

That 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

    
asked by anonymous 13.10.2017 / 14:48

1 answer

1

I found the solution to my problem for everyone with the problem here is solution .

    
13.10.2017 / 15:11