Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progressdialog isshowing returns true even called hide

Tags:

android

I have created progress dialog like this

public VolleyService(Context context, VolleyServiceCompletedListener listener){
    this.context = context;
    pDialog = new ProgressDialog(context);
    pDialog.setMessage("Loading...");
    pDialog.setCancelable(false);
    this.listener = listener;
}

and tried to show progress dialog using this method.

private void showProgressDialog() {
    boolean isShowing = pDialog.isShowing();
    if (!isShowing)
        pDialog.show();
}

And hide the dialog using this method.

private void hideProgressDialog() {
    if (pDialog.isShowing()) {
        pDialog.hide();
    }
} 

The problem is pDialog.isShowing() returns true even after I have called the pDialog.hide(). When I see the hide() method from android.app.Dialog.java they didn't assign the mShowing variable as false, but when I call show() they assigned the mShowing variable as true.

So is there any reason behind they didn't make as false? And how can I open the same progress dialog again?

like image 371
Gunaseelan Avatar asked Feb 26 '16 06:02

Gunaseelan


2 Answers

don't use hide() use dismiss() instead. This will also prevent leaked window error

refer to this link for more info

like image 79
Ankit Aggarwal Avatar answered Oct 24 '22 13:10

Ankit Aggarwal


Please try to dismiss your dialog.

pDialog.dismiss()
like image 43
Amsheer Avatar answered Oct 24 '22 11:10

Amsheer