title: AsyncTask onPostExecute not called
body: <p>I have a simple widget with <code>TextView</code>'s. One <code>TextView</code> should display information obtained from a webpage, and I'm using  this to achieve it:</p>
  
  <pre><code>private class DownloadWebpageTask extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
  
          // params comes from the execute() call: params[0] is the url.
          try {
              return downloadUrl(urls[0]);
          } catch (IOException e) {
              return getString(R.string.srv_dwn);
          }
      }
      // onPostExecute displays the results of the AsyncTask.
      @Override
      protected void onPostExecute(String result) {
          widgetText1 = result;
      }
  }
  </code></pre>
  
  <p>The <code>DownloadWebpageTask</code> is called from an activity, like this:</p>
  
  <pre><code>    DownloadWebpageTask downloadWebpageTask = new DownloadWebpageTask();
      Context context = this;
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
      RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.example_appwidget);
      ComponentName thisWidget = new ComponentName(context, Widget.class);
  
      ConnectivityManager cm =
              (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo netInfo = cm.getActiveNetworkInfo();
  
      if (netInfo != null &amp;&amp; netInfo.isConnected())
      {
          remoteViews.setViewVisibility(R.id.widgettext1, View.VISIBLE);
          netInfo = cm.getActiveNetworkInfo();
          widgetText2 = netInfo.getTypeName();
  
          downloadWebpageTask.execute("http://checkip.amazonaws.com/");
  
          remoteViews.setTextViewText(R.id.widgettext1, widgetText1);
          remoteViews.setTextViewText(R.id.widgettext2, widgetText2);
          appWidgetManager.updateAppWidget(thisWidget, remoteViews);
      }
      else
      {
          remoteViews.setTextViewText(R.id.widgettext1, widgetText1);
          remoteViews.setViewVisibility(R.id.widgettext1, View.GONE);
          remoteViews.setTextViewText(R.id.widgettext2, getString(R.string.tbl_no_connection));
          appWidgetManager.updateAppWidget(thisWidget, remoteViews);
      }
  </code></pre>
  
  <p>This variable is defined in my <code>Activity</code> class and should display the result of <code>AsyncTask</code> but does not.</p>
  
  <pre><code>public String widgetText1 = "initialtext";
  </code></pre>
  
  <p>Step-by-step debugging shows that <code>onPostExecute</code> is never called and the text in the <code>TextView</code> is still 'initialtext'.</p>
  
  <p>Second <code>TextView</code> updates as required since it doesn't involve an <code>AsyncTask</code>.</p>
  
  <p>Similar code including <code>DownloadWebpageTask</code> works fine in my main activity, though.</p>