Count Down Timer in Android

Count Down Timer in Android

Today we are going to create a CountDownTimer in Android. CountDownTimer is used to Schedule a countdown until a time in the future, with regular notifications on intervals along the way. For this we are going to use inbuilt CountDownTimer abstract class.

Basically CountDownTimer is working on Seconds but we can manipulate it to work on Minutes, Hours or Days. So in this tutorial also we are going to convert seconds into Hour, Minutes and Seconds.


1. Create a new project in Android Studio by navigating to File ⇒ New ⇒ New Project and fill required details. By default my activity is

2. Open strings.xml located under res=>values folder and add following strings. These strings are going to be used in this example.

3. Now create a layout naming activity_main.xml and add the following code. In this there are two button for start/stop and reset timer, an EditText for entering no of minutes to run timer and a TextView for running timer.

4. The below method startTimer(int noOfMinutes) is going to be used for countdown timer. There are  three methods in CountDownTimer class:

  • onTick(long millisUntilFinished) – When a count down start this method will run and we can display the Tick over TextView.
  • onFinish() – When CountDown finished then this method called.
  • onCancel() – This method is used for cancelling CountDownTimer.
5. Finally come to your and add the following code. The code is very simple to use CountDownTimer. You can implement this code in your project.
6. Finally, run the application and you will get the output as shown in video.

Thanks. :)

Download Source Code


About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.


It will work well but when i close application it stops and reset from start. so can you help me how can i start timer from left time.

    HI Madhav,

    To start the timer from where you left it, You have to save the last time in SharedPreferences and then when you open your activity again that time read the value from SharedPreference. If value exist start timer from there else start from 0.



Hello Dr.Droid

I wanted to create a multi countdown ,.Can you help me,.??



Thanks you.
i will use in my project


    Sory Dr. Droid

    I can not understand all of that code
    please give me a tutorial from you



Can you explain me how to make a resume button in this code.

Thanks in advanced 🙂 !

    Hi Dilyan,

    Unfortunately there is no resume functionality in Count Down but there is other way to do this. For this whenever you stop the timer you need to save the time in SharedPreference and when you click on Resume button that time get the remaining time by subtracting total time – save time = time_remaining. This remaining_time will be your current time for which you have to run the count down.
    Hope you understand.



How to manipulate it for number of days, as i am trying but its not giving the correct value

    Hi PPPP,

    I don’t know what logic you are using. I am telling my logic please cross check with yours one and try it.

    1. Convert the milliseconds into hours.
    2. After convert hours into number of days by : hours/24.

    In this way you will get the countdown timer into number of days.



thankew best Tutorial <3

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)