title: Show ProgressDialog after clicking on AlertDialog button
body: <p>I have <code>AlertDialog</code> and I want to show <code>ProgressDialog</code> after clicking on <code>AlertDialog</code> positive button (during Internet connection - <code>AsyncTask</code>). Problem is that Progress dialog shows only after finishing task and when <code>AlertDialog</code> is closed. I tried to hide() or dismiss() <code>AlertDialog</code> but it doesnt work.</p>
  
  <p>Any idea how to show ProgressDialog in front of AlertDialog? This is my code.</p>
  
  <pre><code>LayoutInflater li = LayoutInflater.from(kontekst);
  final View vNearest;
  vNearest  = li.inflate(R.layout.nearest, null);
  
  AlertDialog.Builder builder = new AlertDialog.Builder(kontekst);
  builder.setView(vNearest);
  builder.setCancelable(true);
  
  builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
  
      @Override
      public void onClick(DialogInterface dialog, int witch) {
  
      String xml = "www.example.com";
      MarkerOptions nearestMO = new  DownloadXmlTask().execute(xml).get();
      String distance = nearestMO.getSnippet();
  
        }
      }); 
  </code></pre>
  
  <p><em><strong>DownloadXmlTask AsyncTask:</em></strong></p>
  
  <pre><code>private class DownloadXmlTask extends AsyncTask&lt;String, Integer, MarkerOptions&gt; {
  
  ProgressDialog waitDialog;
  
  @Override
      protected void onPreExecute() {
      super.onPreExecute();
      waitDialog = ProgressDialog.show(Home.this, "Working", "Please Wait", true, true);
      waitDialog.setCanceledOnTouchOutside(false);
  }
  
  @Override
  protected MarkerOptions doInBackground(String... urls) {
  
      try{             
          URL xmlURL= new URL(urls[0]);           
          SAXParserFactory spf = SAXParserFactory.newInstance();
          SAXParser sp = spf.newSAXParser();
          XMLReader xr = sp.getXMLReader();
          HandlingXMLStuff readingXML = new HandlingXMLStuff();
          xr.setContentHandler(readingXML);
          xr.parse(new InputSource(xmlURL.openStream()));
  
          return readingXML.getNearest();
  
      } catch (Exception e) {
          return null;
      }
  }
    protected void onPostExecute(MarkerOptions result) {
      super.onPostExecute(result);
              waitDialog.dismiss();
  }
  
  }
  </code></pre>