Using toast inside timertask
<p>Found someone has similar issue online <a href="http://ranger1976.blogspot.com/2009/04/cant-make-toast-from-timertask-while.html" rel="nofollow">here</a>.</p>

<p>This doesn't work:</p>

<pre><code>Timer t = new Timer(false);
t.schedule(new TimerTask() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "msg", Toast.LENGTH_LONG).show();
}
}, 5000);
</code></pre>

<p>But if I instantiate the toast outside the timertask then show it inside <code>run</code>,it works.</p>

<p>I think it may relate to the so-called UI thread,</p>

<p>but how exactly ?</p>
