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