Homework 2– stackhcj
For this homework, I decided to make an application that recorded the distance you (or rather your phone) has gone using the GPS function on the phone. I had originally made this application with the idea of the user using it to track the amount of time it takes them to run a certain distance. However, I think you can use it for more than that. If you want to see how long it takes you to a certain distance (via car, bike, skateboard, snowboard, etc) .
When you press start, a timer pops up and starts showing a timer. During this time you may press stop or view distances. However, if you try to press save, a dialog box pops up and asks you to stop the timer before saving it.
The timer function in android is kind of silly and I really wasn’t impressed with what I could do with the timer. So, I decided to make my own. This actually worked out fairly well for me and shows the user what they need to see. The only downfall to it was that I wish I would have been able to call a timer.getText() function on it that would return something that I could “add” to the “new” timer when the onResume() method was called. However, I found a fairly simple solution to this problem. I stored the starting time and called the startTimer() method again, but only if the startTime was not at its default value, as I did not want the timer to start automatically anytime that you opened the app.
Once you press the Save button, it brings you to the database where all of your other “distances” are located. I decided to make the database a ListView, because it seems the easiest and very user-friendly. Each time that a distance is saved, it is added to the database. Each of these are shown by date (if you are intending to use this application for what I originally had in mind– tracking the different times run, this is beneficial so that you can see how much progress you have made over time).
Once in the ListView (database), you can tap on any of the “distances” and see their contents. In this view, you are shown everything that makes up a distance (date, time, distance).
The only downfall I had with this application was that I REALLY wanted to save the distance in the onPause() method, but you cannot use the SharedPrefrences.Editor to store doubles. So, I had to cast the distance from a double to an int. I don’t think it will make too much difference (as long as the user isn’t muddling with their phone while running, driving, etc, it should be fine.)