1. sylsau's Avatar

    I create that thread to present you a tutorial showing you how to create a a Countdown Timer on Android. The tutorial is also available on my website here : Learn to create a Countdown Timer on Android .

    Sometimes, when you make Android applications, you need to create a countdown. It can be useful in a board game for example if the player have a defined time to play.

    A lot of solutions exist to create a countdown in Java. Some are more complex than other.

    On Android, the SDK offers to developers an easy way to create a countdown timer : a dedicated class named CountDownTimer.

    1/ Create the CountDown Timer

    Here, we consider a countdown of 60 seconds. So, we need to use the following code to create the CountDownTimer instance :

    CountDownTimer countDownTimer = new CountDownTimer(60 * 1000, 1000) {
       public void onTick(long millisUntilFinished) {
          mTextField.setText("Seconds remaining: " + millisUntilFinished / 1000);
       public void onFinish() {
          mTextField.setText("Done !");
    The second parameter lets you to define at which interval you must be notified during the countdown. You can update your User Interface in that method.

    2/ Manage your CountDown Timer

    Once you have created your CountDownTimer object, you have to manage it. First, you can start it :

    If you want to cancel your countdown timer before its end, you have just to call its cancel() method :

    3/ Conclusion

    Powerful and easy to use, the CountDownTimer class is the ideal solution to create countdown timer on Android.

    4/ Extra

    You can also enjoy this tutorial on Youtube :

    Don't hesitate to give me your feedbacks and ideas for new tutorials.


    B. Diddy likes this.
    08-02-2016 02:28 AM
  2. B. Diddy's Avatar
    Excellent--thanks for posting this!
    08-02-2016 12:33 PM

Similar Threads

  1. any app to prevent phone from switch off?
    By AC Question in forum Ask a Question
    Replies: 2
    Last Post: 08-02-2016, 02:00 PM
  2. Can't load pokemon on my new phone zte grand 3
    By omnitide in forum Android Games
    Replies: 3
    Last Post: 08-02-2016, 02:25 AM
  3. Replies: 0
    Last Post: 08-02-2016, 02:21 AM
  4. Quick Charge 2.0/3.0 to charge 12v Device?
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 08-02-2016, 01:38 AM
  5. Trouble Charging & Fast Battery Drain-Android Tablet
    By AC Question in forum Ask a Question
    Replies: 0
    Last Post: 08-02-2016, 01:13 AM

Tags for this Thread