Proper way to get a Recurring Callback on the UI thread
<p>I would like to get a recurring call back to invalidate a view.  I am sure there is a neat way to do this.  I am currently doing this and would like a neater / better solution if possible?</p>

<pre><code>new Thread()
    {
        @Override
        public void run()
        {
            while (!Thread.currentThread().isInterrupted())
            {
                handler.post(new Runnable()
                {
                    public void run()
                    {
                        BannerButton.this.invalidate();
                    }
                });
                try
                {
                    Thread.sleep(50); // yields 20 fps
                } catch (InterruptedException e)
                {
                    Thread.currentThread().interrupt();
                }
            }
        }
    }.start();
</code></pre>

<p>For a single shot timer on the UI thread, I do this: (But I cant find a way to do this with repeats)</p>

<pre><code>(new Handler()).postDelayed(new Runnable()
    {
        @Override
        public void run()
        {
            // Do stuff
        }
    }, SPLASH_SHOW_TIME);
</code></pre>

<p><a href="http://developer.android.com/reference/java/util/Timer.html" rel="nofollow">Timer</a> looked good, but it calls on a background thread. </p>

<p>Thanks.</p>
