title: Having a reference to an object inside asynctasks stops it from updating UI
body: <pre><code>public class Container {
  
      public process(T result){
         // Update UI
      }
  
      public anotherMethodThatUpdatesUI(T result){
         // Update UI
      }
      public SomeTask extends AsyncTask&lt;T,T,T&gt; {
          private Container container;
          public someTask(Container container){
              this.container = container; 
          }
  
          protected void onPostExecute(T result) {
              super.onPostExecute(result);
              container.process(result);
  
          }
      }
  }
  </code></pre>
  
  <p>I first call the <code>AsyncTask</code> <code>execute</code> method which works correctly. But after that calling <code>anotherMethodThatUpdatesUI</code> fails with this exception:</p>
  
  <pre><code>Can't create handler inside thread that has not called Looper.prepare()
  </code></pre>
  
  <p>But if I remove the refrence to <code>Container</code> inside the <code>AsyncTask</code> and call <code>process</code> directly. I don't get the error.</p>
  
  <pre><code>public SomeTask extends AsyncTask&lt;T,T,T&gt; {
      private Container container;
      public someTask(Container container){
          // this.container = container; 
      }
  
      protected void onPostExecute(T result) {
          super.onPostExecute(result);
          process(result);
      }
  }
  </code></pre>