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 Research A Neighbourhood Before You Move

Moving homes is a long process with plenty of things to remember, but before you secure the purchase…
Read more
How ToLifestyle

How to select the beautiful painting for living room

Living rooms and family rooms are typically the most utilized spaces in the home. This is…
Read more
How To

How to Gear Up Your SEO Strategy for 2021

Over the years, Sydney has managed to gain recognition for its strong economy and business…
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"]