title: progress dialog circle only showing after task
body: <p>i've an progress circle that is set inside an AsyncTask. It shows for about a second as the asynctask is executing, then disappears. once the task is completed if i press the back button the circle shows for a long time. why is this?</p>
  
  <pre><code>private class AsyncGetRota extends AsyncTask&lt;String, Void, Void&gt; {
  
          ProgressDialog progressDialog;
  
  
          @Override
          protected void onPreExecute()
          {
              progressDialog= ProgressDialog.show(NfcscannerActivity.this, 
                      "Connecting to Server"," retrieving rota...", true);
  
              //do initialization of required objects objects here                
          };      
  
  
          @Override
          protected Void doInBackground(String... params) {
  
  
  
              try {
                  Log.e(TAG, "inside doInBackground");
                  rotaArray = nfcscannerapplication.loginWebservice.getRota(params[0], params[1]);
  
                  cancel(true);
  
  
  
              } catch (Exception e) {
                 e.printStackTrace();
              }
              return null;
  
          }
  
          @Override
          protected void onPostExecute(Void result)
          {
              super.onPostExecute(result);
              progressDialog.dismiss();
          };
  
  
  
      }
  </code></pre>
  
  <p>[update]</p>
  
  <pre><code>getRota.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      Log.e(TAG, "onclicked getRota");
  
                      String[] params = new String[]{"36", "18-09-2012"}; 
                      AsyncGetRota agr = new AsyncGetRota();
                      agr.execute(params);
  
                      for(int i = 0; i &lt; 60; i++){
  
                          if(agr.isCancelled() == true){
                              Log.e(TAG, "asyncTask is finished");
                              break;
                          }
  
  
                          try {
                              Thread.sleep(1000);
                          } catch (InterruptedException e) {
                              e.printStackTrace();
                          }
                      }//end of for loop
  
                      Intent intent = new Intent(NfcscannerActivity.this,
                              GetRota.class);
  
                      Bundle b = new Bundle();
                      b.putSerializable("rotaArray", rotaArray);
  
                      intent.putExtra("rotaArrayBundle", b);
                      startActivity(intent);
  
                  }// end of onclick
              });
  </code></pre>