The total duration the timer will run for, a.k.a how far in the future you want the timer to end. In milliseconds.
The interval at which you would like to receive timer updates. In milliseconds.
A parameter provided in onTick() that tells how long the CountDownTimer has remaining. In milliseconds
CountDownTimer is a pretty lean class - it does one thing very well. Since you can only start/cancel a CountDownTimer, you have to implement pause/resume functionality as shown in the second example. For more complex functionality, or to specify a timer that should run indefinitely, use the Timer object.
A More Complex Example
In this example, we will pause/resume the CountDownTimer based off of the Activity lifecycle.
Creating a simple countdown timer
CountDownTimer is useful for repeatedly performing an action in a steady interval for a set duration. In this example, we will update a text view every second for 30 seconds telling how much time is remaining. Then when the timer finishes, we will set the TextView to say "Done."
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0