title: dismiss progress dialog in asyntask
body: <p><strong>I have search box in my page,I added onTextChangeListener() too. When I am add/removing letters/characters from search box ,every time I am calling same asyntask.Suppose 3 times called then 3 times progress dialog instances getting created and need to dismissed.Here progress dialog is not getting dismissed.</strong></p>
  
  <pre><code>search.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
              }
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  searchresult = search.getText().toString();
  
                  if (count == 0) {
                      pageCount = 1;
                      productsList.clear();
                      mCount = 0;
                      if (isTextWatcherVisible) {
  //                        GetProductsTask();
                          new GetProductsTask().execute();
                      }
                  }
              }
              @Override
              public void afterTextChanged(Editable s) {
              }
          });   
  class GetProductsTask extends AsyncTask&lt;Void, Void, Void&gt; {
  
      final String pcid = Preferences.getString(Preferences.PrefType.enum_company_id, getActivity());
  
      String url1 = getContext().getString(R.string.url) + "products?company_id=" + pcid + "&amp;page=" + pageCount;
  
      public GetProductsTask() {
          progressDialog = new ProgressDialog(getActivity());
          progressDialog.setMessage("Loading...");
          progressDialog.setIndeterminate(false);
          progressDialog.setCancelable(false);
      }
      protected void onPreExecute() {
          super.onPreExecute();
  //                progressDialog = new ProgressDialog(getActivity());
  //                progressDialog.setMessage("Loading...");
  //                progressDialog.setIndeterminate(false);
  //                progressDialog.setCancelable(false);
          progressDialog.show();
  
      }
  
      @Override
      protected Void doInBackground(Void... params) {
        // somthig here
      }
      protected void onPostExecute(Void result) {
          super.onPostExecute(result);
          ProductslistAdapter adapter = new ProductslistAdapter(getActivity(), R.layout.vendor_products_item, productsList, searchresult);
  
          list.setAdapter(adapter);
          int count = pageCount - 1;
          list.setSelection(count * 24);
          if (progressDialog.isShowing())
              progressDialog.dismiss();
  
      }
  </code></pre>