title: How to update UI when using AsyncTask
body: <p>My simple app is set to retrieve RSS feeds when the <code>Refresh</code> button is clicked.<br>
  Clicking the refresh button starts an <code>AsyncTask</code> which retrieves the feeds.  The <code>AsyncTask</code> is a subcalss of the main activity.  </p>
  
  <p>Here is what my class looks like:  </p>
  
  <pre><code>public class NasaDailyImage extends Activity{
      public ProgressDialog modalDialog = null; //problematic
  //------------------------------------------------------------------------------
      @Override
      protected void onCreate(Bundle savedInstanceState){
          //instantiate the ProgressDialog
          Button b = //get reference to button
          b.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  modalDialog.show(); // show modal
                  Toast.makeText(getApplicationContext(), "Getting feeds", 500).show();
                  new AsyncRetriever().execute(new IotdHandler()); // Get the feeds !!
              }
          });
      }
  //------------------------------------------------------------------------------
      public synchronized void resetDisplay(boolean parseErrorOccured, 
          boolean imageErrorOccured,
          IotdHandler newFeeds){
          if(parseErrorOccured || imageErrorOccured){
              // make a Toast
              // do not update display
          }else{
              // make a Toast
              // update display
              // based on new feed
          }
      }
  //------------------------------------------------------------------------------
      class AsyncRetriever extends AsyncTask&lt;IotdHandler,Void,IotdHandler&gt;{
  
          @Override
          protected IotdHandler doInBackground(IotdHandler... arg0) {
              IotdHandler handler = arg0[0];
              handler.processFeed(); // get the RSS feed data !
              return handler;
          }
  //------------------------------------------------------------------------------    
          @Override
          protected void onPostExecute(IotdHandler fromInBackground){
              resetDisplay( // call to update the display
              fromInBackground.errorOccured,
              fromInBackground.imageError,
              fromInBackground);
          }
  //------------------------------------------------------------------------------
  
  
  }  
  </code></pre>
  
  <p>The problem is with <code>show()</code> of <code>modalDialog</code> in the <code>onCLickListener</code>. That causes my app to crash. <strong>Why?</strong> and <strong>how do I solve it?</strong></p>