title: Progress Dialog for AsyncTask - Android
body: <p>I'm trying to show a progress dialog while the twitter feed is loading up...However the progress dialog remains on screen when the twitter feed appears. Any help is much appreciated.</p>
  
  <pre><code>public class MainActivity extends ListActivity {
  
      final static String twitterScreenName = "CFABUK";
      final static String TAG = "MainActivity";
      private AsyncTask&lt;Object, Void, ArrayList&lt;TwitterTweet&gt;&gt; tat;
      boolean done;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          done=false;
          AndroidNetworkUtility androidNetworkUtility = new AndroidNetworkUtility();
          if (androidNetworkUtility.isConnected(this)) {
              TwitterAsyncTask syn=new TwitterAsyncTask();
              syn.execute(twitterScreenName,this);
  
  
              ProgressDialog pd = new ProgressDialog(MainActivity.this);
              pd.setMessage("loading");
              pd.show();
  
              do {
                  if(!(syn.getStatus()==AsyncTask.Status.RUNNING)) {
                  pd.dismiss();
                  pd.cancel();
                  done=true;
                  }
              } while(done=false);
  
  
          } else {
              Log.v(TAG, "Network not Available!");
          }
      }
  }
  </code></pre>