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 Make Aging Easier for Those in Their Senior Years

Aging is an inevitability in everyone’s life. It is a time when our mind and body begins to slow…
Read more
How To

Hiring for a Startup: How to Find the Right Hires

For startups, the right hires can make a huge difference. They can be the foundation upon which you…
Read more
BusinessHow To

How Long-Tail Keywords Unlock Small Business Search Traffic

‘Men’s shoes’. ‘Buy men’s shoes’. ‘Shoes for men’. The head term keywords that…
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"]