6

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?

Gunaseelan
  • 14,415
  • 11
  • 80
  • 128

2 Answers2

10

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

refer to this link for more info

Community
  • 1
  • 1
Ankit Aggarwal
  • 5,317
  • 2
  • 30
  • 53
3

Please try to dismiss your dialog.

pDialog.dismiss()
Amsheer
  • 7,046
  • 8
  • 47
  • 81