title: Error in derived TimerTask class: `Can't create handler inside thread that has not called Looper.prepare()`
body: <p>I want to cyclically update an Android Layout. For this purpose I wrote a short class derived from <code>TimerTask</code>.
  Unfortunately my code causes an exception and I do not really know, what the problem might be. :( </p>
  
  <p>So maybe anybody could help.</p>
  
  <p>Thanks </p>
  
  <p>Chris</p>
  
  <p>Here's my code:
  In the main activity I've got:</p>
  
  <pre><code>private MyLayoutClass m_MyLayout;
  
  ...
  
  public void onCreate(Bundle savedInstanceState)
  {
    ...
    m_MyLayout = new AdLayout(this);
  
    Timer caretaker = new Timer();
    caretaker.schedule(new MyReloadTimerTask(m_MyLayout), 1000, 5000);
    ...
  }
  </code></pre>
  
  <p>This is my derived TimerTask class:</p>
  
  <pre><code>public class MyReloadTimerTask  extends TimerTask
  {
    private MyLayoutClass m_MyLayout;
  
  
    public MyReloadTimerTask(MyLayoutClass aLayout)
    {
      m_MyLayout = aLayout;
    }
  
  
    @Override
    public void run()
    {
      m_MyLayout.doReload();
    }
  }
  </code></pre>
  
  <p>The doReload() cannot be executed, I get an exception with this message: <code>Can't create handler inside thread that has not called Looper.prepare()</code></p>