Android CountDownTimer

rantravee picture rantravee · Apr 22, 2010 · Viewed 8k times · Source

When writing :

 CountDownTimer timer = new CountDownTimer(1000, 100) 
 {
      @Override
       public void onTick(long l) 
       {

       }

       @Override
       public void onFinish() 
       {

       };
 }.start();

are we actually starting a new thread that handles ticks? If not, what is really happening?

Answer

CommonsWare picture CommonsWare · Apr 22, 2010

CountDownTimer's implementation uses Handler and sendMessageDelayed(), so no background thread is needed. This does mean that the timer will not update if you are tying up the main application thread elsewhere in your code.