• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps HELP! School Project - Timer Application

Joshnerd

Lurker
Okay, so our teacher has issued us a project to make something (pretty much, anything) that countdown (or up) from 10mins. So most people are doing sand timers etc; However I have chosen to build an application. This is due 18th November... So i do not have much time. I need to know how to start coding the timer. What i need to know is the code involved. (I have learnt some bits and pieces of android development) Any help very much appreciated.. :D
 
Assuming you know the basics of creating Android apps, this should be fairly easy with one potentially tricky bit.

- For the layout, you'll need a start and stop button, and a TextView to display the remaining time.

- You'll need two state variables: an integer for the number of seconds remaining, and a boolean to hold the state of the clock. (is it running?)

- Now for the tricky bit. You can't have a loop within the main UI thread counting down the timer, else your app will freeze. You'll need to create a thread that takes 1 away from the remaining seconds variable, and then sleeps for 1 second. You'll also need to make it interruptable when the user presses the Stop and Start buttons. This guide should be a good start for learning about threads.

Those are a few tips that'll help you plan out your app, how you implement that advice is up to you. :)
 
Back
Top Bottom