Reputation: 11665
I have a simple waitdialog which I try to display. Display is working, but dismiss is not working. Dialog shows forever. Does anyone see the problem ?
regards
ProgressDialog waitDialog;
waitDialog=new ProgressDialog(this);
waitDialog.show(this, "wait","wait");
5secondstask();
waitDialog.dismiss();
Also without executing the 5secondstaks() and showing and directly dismissing it it shows forever.
ProgressDialog waitDialog;
waitDialog=new ProgressDialog(this);
waitDialog.show(this, "wait","wait");
waitDialog.dismiss();
Upvotes: 0
Views: 101
Reputation: 28484
DO this way.
ProgressDialog waitDialog;
waitDialog = ProgressDialog.show(this, "wait","wait");
5secondstask();
waitDialog.dismiss();
UPDATE EXPLAINATION
In your case not working because the progressdialog you create using waitDialog=new ProgressDialog(this);
is reference by "waitDialog" variable. But when you call show method it returns another object of progressdialog. which is not reference by "waitDialog" variable.
Because show() is static method which returns new object of progressdialog.
Your case will also work if assign reference to "waitDialog" variable.
ProgressDialog waitDialog;
waitDialog=new ProgressDialog(this);
waitDialog=waitDialog.show(this, "wait","wait");//UPDATE here to work with your case
5secondstask();
waitDialog.dismiss();
Upvotes: 1