Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Program: A Simple CountDownTimer example

Problem:

Require a simple count down timer

Solution:

Android comes with a built-in class for constructing CountDownTimers. Its easy to use, efficient and works..(that goes without saying!).
  • Create a subclass of CountDownTimer.
  • Override the onTick() and onFinish() methods.
  • Instantiate a new instance in your Android Activity,
  • Call the start() method on the new instance created!

    Discussion:

    File: main.xml width="fillparent" android:layoutheight="fillparent">