Build a simple digital stopwatch that keep
track of the time in tenths of a second. The stopwatch should contain
"Start", "Stop" and "Reset" buttons. To help guide you through this
project, we suggest that you download the provided program template for this project and build your stopwatch program as follows:
Mini-project development process
- Construct a timer with an associated interval of 0.1 seconds
whose event handler increments a global integer. This integer will keep
track of the time in tenths of seconds. Test your timer by printing
the global integer to the console. To stop the timer and print
statements, use the reset button in upper left. Important: Do not
use floating point numbers to keep track of tenths of a second! While
it's certainly possible to get it working, the imprecision of floating
point can make your life miserable. Use an integer instead, i.e., 12
represents 1.2 seconds.
- Write the event handler function for the canvas that draws the
current time(simply as an integer, you should not worry about formating
it yet) in the middle of the canvas. Remember that you will need to
convert the current time into a string using
strbefore drawing it.
- Add "Start" and "Stop" buttons whose event handlers start and
stop the timer. Next, add a "Reset" button that stops the timer and
reset the current time to zero.
- Next, write a helper function
format(t)that returns a string of the form
A, B, Cand
Dare digits in the range 0-9. Test this function independent of your project. Note that your helper function
formatshould always draw leading zeros correctly. For example
format(0) == 0:00.0
format(11) = 0:01.1
format(321) = 0:32.1
format(613) = 1:01.3
Hint: Use integer division and remainder (modular arithmetic) to
extract various digits for the formatted time from the global integer
- Insert the
formatfunction into your canvas event handler will complete the stopwatch.
Finally, to turn your stopwatch into a test of reflexes, add to two
numerical counters that keep track of the number of times that you have
stopped the watch and how many times you manage to stop the watch on a
whole second. These counters should be drawn in the upper lefthand part
of the stopwatch canvas in the
xis the number of successful stops and
is number of total stops. My best effort at this simple game is around
a 25% success rate. Note that hitting the "Stop" button when the timer
is already stopped should not change your score.
- Modify "Reset" so as to set these number back to zero when clicked.
The output would look something like this.
Need help with directions? Or want to know where you are? Google Maps is one of the great service that Google provides to the masses free of cost. Using Maps in your android application is easy as long as you know what you are doing. In this tutorial I will demonstrate a simple application which will display your current position in a map and update it every time you move.
Step 1: Get a Google Maps API key
Before doing anything you need to get a MD5 key which will allow you to use the API in your application. To get a key you first need to create a simple certificate fingerprint. For this tutorial I have created a SDK Debug Certificate which has to be used for development. I am using eclipse for developing this application so to create the certificate I first needed to locate my debug.keystore file. I found the location in Eclipse by using Window->Preferences->Android->Build. Once I got the location I ran a simple command on the command prompt:
Web Services and Service Oriented Computing has revolutionized the internet in the past decade. It is quite true that without web services most Apps in the App Store will not be that interesting!!
Mobile devices have a limited processing power so it becomes necessary to let a web server do the heavy lifting when it comes to computation. So in this tutorial I am bringing you a way to use RESTful webservice in your android app and parse the XML response.
The example web service that I am using is here. This web service lets you access current price of Stock based on its trading symbol.
Step 1: Know Thy Web Service
Before calling any web service you must know how to call it and what you will get in response. This web service is a RESTful service so calling it is easy using a GET request.
- GET /stockquote.asmx/GetQuote?symbol=string HTTP/1.1
- Host: www.webservicex.net
SMS - Short Message Service is very effective and quick way of communication. Your app may have a use case wherein it needs to send SMS to someone. So lets see how it can done, it is relative simple as you would see below:
Step 1: Creating the project
This is the simplest step of them all. Just go to your project wizard and create a new project with the following details:
Project name: SendSms2.3
Application name: SendSms2.3
Package name: send.sms
Minimum Required SDK: API 8
Target SDK: API 10
Main Activity: SendSmsActivity
Layout name: main
What was the first thing that you did when you logged on to a Computer the first time? For me, it was Microsoft Paint. As a child who never drew a circular-circle in her entire life, it was exciting to draw perfect circles, rectangles and straight lines. And now when I see kids painting their first painting on an Android app it reminds me of my childhood.
In this post, I am bringing you a simple trivia quiz. The subject of questions is computer science in this app but I think it is obvious that you can keep it any way you like. The app in this tutorial reads questions from a database and marks you out of 5 for your performance. The questions are asked one by one using a single layout as you will see as I proceed.
The scripting language Python is easy to use, and thus very convenient to program simple games. And to make it even simpler, there one Python module which is dedicated to games creation: pygame. It makes you life much easier when programming a game as it takes care of the user input, the graphics and the sound effects.
To install it, if you are using Ubuntu as I did for this tutorial, you can simply install it by typing this command in a terminal:
sudo apt-get install
If you are using another
operating system, please refer to the
downloads page of the pygame website.
The web has significantly evolved during the last years. Blogs, social networks, and web-based applications are some modern applications of the Internet that were never even imagined when the HTML 4.01 specification was released in 1999. Basically, what HTML5 adds compared to the previous specification is a brand new set of tags to improve the functionalities of HTML.
With the introduction of XCode 4, a lot of shortcuts have changed. There are a lot of shortcuts but its kind of difficult to remember all, esp. when you are new to XCode knowing the most common shortcuts will give you most bang for you buck. The following are the most essentials ones that any developer would need to learn to be productive.
Storing data locally in Android is very easy. Here are few ways we can do it:
- Using SharedPreferences
- Using Files
- Using SQL databases.
This tutorial will tell you how to save data using SQL databases. For this we are taking a very simple application which stores a very simple list of tasks with their boolean status: done or not done.
The database contains only one table called "task" which has the following columns:
This tutorial will show us how to save data in a SQL database. For this we are would build a very simple application which stores a list of tasks with their boolean status(whether done or not done).
- The log is reference to the
5 weeks 3 days ago
- What is log here
5 weeks 4 days ago
- Loved this tutorial. First
6 weeks 4 days ago
- Hello it's me, I am also
9 weeks 4 days ago
- Thanks for this great
11 weeks 1 day ago
- The updated project has been
11 weeks 3 days ago
- Great tutorial, it really
11 weeks 4 days ago
- @Kaitain - That is correct,
11 weeks 4 days ago
First of all a big thank
12 weeks 22 hours ago
- What on earth is this code
13 weeks 5 days ago