AndroidHow To

Learn to Develop A Simple Count Down Timer Application

Hello, nice to meet you again.

Today, I will develop a simple count down timer application. This is only a simple application which show you how to create a function to let time count down. You can use it in your larger application like Alarm Alert, …

Now, let’s do it.

First, create new Android project. I always use Android 2.3.3 for Minium Required SDK, lasted Android version (now is 4.3) in Target SDK and Android 2.3.3 for Compile With. OK, Next and Next. I finish creating new project.

IN MAIN_ACTIVITY.XML

Create a TextView

 

OK, we switch to MainActivity.java file

IN MAINACTIVITY.JAVA FILE

Create a CountDownTimer object.

Create a TextView object.

In onCreate, write a code to create a new CountDownTimer which has 2 parameters

First Parameter: the total time (ex: 2 minutes 30 seconds, we change to milliseconds: 150000).

Second Parameter: the time which the action will repeat.

onTick: will be called after a time.

onFinish: will called after the total time finishes.

 

We also have to write a function called format Time which has parameter millis.

OK, it is ok. I will test it to know that if it works well or not.

Yeah, it works well. Hope you can do that.

About author

Articles

Morris is a Technology enthusiast and a writer by night. He has been a part of TheTechly for quite some time and he contributes knowledgeable news articles from the Technology niche.
Related posts
How To

How to Get Back Behind the Wheel After an Accident

Getting into a car accident can be a deeply traumatizing and even life-altering event. Once you have…
Read more
How To

How to Keep Threat Detection a Priority

Cyber-attacks are becoming increasingly common, and every business should implement a strategy to…
Read more
How To

How security access systems work & basic guide to automated door access systems

Protecting our property is one of the most important considerations in the modern age and, with…
Read more
Newsletter
Become a Trendsetter

Sign up for TheTechly’s Daily Digest and get the latest and trending technology updates.

[mc4wp_form id="729"]