Skip to content Skip to sidebar Skip to footer

Android - Why Would Dialog Not Close Upon Dialog.dismiss()

I have a bit of a strange problem. When an activity starts, I show a dialog saying that some items are loading like this: Dialog dialog; @Override public void onCreate(Bundle sav

Solution 1:

Make sure that when you are executing dialog.dismiss that it is pointing to the dialog you created. You have dialog as a class variable and there is a high chance it was assigned another dialog by the time of dismissal come. I had this one and turned out that dialog variable at dismiss time was no longer pointing to my actually dialog.

Putting a break point and seeing if the dialog variable upon creation/execution is still the same will probably help

Solution 2:

Try

ContextmContext= getApplicationContext();
Dialogdialog=newDialog(mContext);

according to the documentation it should be the right way to declare a Dialog.

Post a Comment for "Android - Why Would Dialog Not Close Upon Dialog.dismiss()"