Skip to content
KnowledgeCity

Java for Android: Timer Click Game

Learn for mobile functionality with this Intermediate Java for Android Programming course.
Preview the first lesson free — get full access to all 12 lessons.
Course: On-Demand
Intermediate Provider Shad Sluiter  12 Lessons ·  46m  in Arabic, German, English, Spanish, French, Portuguese, Chinese 

Course Description

In this tutorial, you will create a game that demonstrates several features of Android including, background tasks, timers, a progress bar and a game state class. The application shows two buttons that the user clicks as many times as possible in a 30-second time frame. The timer uses a runnable task. The progress bar displays the remaining time. The buttons are enabled and disabled to make the game work properly. The game state class is designed to encapsulate all the properties of the game including the remaining time and score.

What You'll Learn

  • Demonstrate the use of background tasks in an Android application
  • Set a timer and display the remaining time in a progress bar
  • Design a game state class that encapsulates multiple application properties such as remaining time and score
  • Programmatically enable and disable buttons to control game flow
  • Attach a shared click listener to multiple buttons
  • Use a postDelay handler to run a clock and delete a callback to stop it

Key Takeaways

  • The course builds a game in which the user clicks two buttons as many times as possible within a 30-second time frame.
  • The timer is implemented using a runnable task, and the progress bar displays the remaining time.
  • Buttons are enabled and disabled to make the game work properly.
  • A game state class encapsulates all the properties of the game, including the remaining time and the score.
  • The tutorial covers starting and stopping the clock, calculating the game score, and checking for the time limit to end the game.

Frequently Asked Questions

What will I build in this course?

You will create an Android game that shows two buttons which the user clicks as many times as possible in a 30-second time frame, using background tasks, a timer, a progress bar, and a game state class.

How does the timer and progress bar work in this game?

The timer uses a runnable task, and the progress bar displays the remaining time. The course covers using a postDelay handler for the clock, deleting a callback to stop the clock, updating the progress bar, and checking for the time limit to end the game.

What Android development skills does this course cover?

It covers Android Applications, Android Development, Android UI, AsyncTask, Java GUIs, and Real Time Java.

What is the purpose of the game state class?

The game state class is designed to encapsulate all the properties of the game, including the remaining time and the score, demonstrating how to design a class that encapsulates multiple properties of an application.