title: Using CountDownTimer from background thread in Android
body: <p>I want to use a CountDownTimer to update a text in UI thread from background thread that only counts time left.</p>
  
  <p>I subclassed a thread and pass main thread handler in its constructor and creating a new CountDownTimer in run method to update text view in main ui thread as follows:</p>
  
  <pre><code>class MyCounter extends Thread
  {
     private Handler uiHandler;
     private long timeToCount;
  
     public MyCounter(Handler handler, long time)
     {
       this.uiHandler = handler;
       this.timeToCount = time;
     }
  
  public void run()
  {
    new CountDownTimer(timeToCount, 1000){
         public void onTick(long millisUntilFinished) {
             Message msg =  Message.obtain();
             String timeString = //....here I conver millisUntilFinished to String format
             msg.obj = timeString;
             uiHandler.sendMessage(msg);
         }
  
        .... //Other method of CountDownTimer
       }.start();
    } //end of run
  } //end of thread class
  </code></pre>
  
  <p>I create MyCounter thread and calling start on my activity UI (main thread) passing an handler created in main thread. I seems that CountDownTimer is not being called after calling start in my main activity.</p>
  
  <p>Any ideas? </p>