GPS Diary

Introduction

A GPS Diary, allows the user to track where they have been yesterday, a week ago or a year ago. The data will be stored on the user’s phone through a SQLite Database and it can be retrieved. The application will have 4 activities: the main activity which acts as a menu page and can turn the GPS service on or off, which will run in the background, the second activity for displaying the database, the third activity for typing out a diary with an automatic timestamp, and the last for displaying the coordinates with markers. This project is important because it tracks one’s movements and also allows one to record information like a traditional diary.

My Exploration

  1. Basic, Standard, and Bonus Functionality
  2. Android Studio
  3. Java Programming
  4. Google API key for Google Maps
  5. Android Phone Sensors
  6. Excessive Debugging and User Testing
navigation through the application
Figure 1: This diagram shows how the user can navigate through the application.

My Tasks

Overview of the Application

I have developed an Android application, GPS Diary, which is designed for busy people who want to maintain a record of their daily activities. This application uses the GPS sensor on the smartphone to automatically record the user’s location every 20 seconds. If the user has time, they could also type in additional information similar to a traditional diary.

The explicit intents are used to transition from activity classes to other activity classes and this will be used when the user moves between the 4 activities. The implicit intent will be demonstrated when the user enters a date in the main activity and presses the Search Date button, resulting in the opening of a web browser. It will also used to access the about page which will give the user more information about the application.

The SQLite database should store data in many columns. 2 columns will be the timestamp data and the other 2 columns will store the longitude and latitude GPS coordinates. By only having one column with date, the user can query for a specific date and find many coordinates through the “Search Location” button.

The shared preferences will be used to store the Diary activity, being the activity where the user can type what they have done and save it into the diary. Shared preference is the easiest and the best method because there is only one value, being the information, and one key, being the date. It is also used to detect if the dialog has been seen before, and other instances.

The sensor that will be used is the accelerometer and it will be used to detect shaking which will allow the data from the written diary to be saved in a SharedPreferences file.

functionalities
Figure 2: This diagram shows how the separate files are divided into their functionalities. This helps with code organization so if someone else were to continue developing this application, they will understand what I have done easily.

Basic Functionality

The basic functionality will be to track the location of phone through the GPS service and record it in the SQLite Data. This will allow the user to view the SQLite date through a recycler viewer. This should only take a week and this is the main purpose of the app, to collect the longitude and latitude values of the app every few seconds to record the location.

This is completely finished and it is accomplished with the DatabaseConstants, MyDatabase, and MyHelper classes as these are responsible for creating the RecyclerView of the SQLite Database with the row.xml and activity_recycler.xml layouts. The GPSService class, extending service, allows the location to be transferred every 20 seconds, by the location sensors on the phone, to the main activity through the broadcast intent. The main activity will add the values to the database once it received new data and it will also timestamp the data so the coordinates can be organized by the date and time it is collected.

Standard Functionality

One standard functionality would be the written diary section which allows the users to write what they have done that day and submit it. This should automatically timestamp the submission and place it into a SQL Database. This is accomplished by using the date collected from the timestamp as the key for SharedPreferences. SharedPreferences is perfect because only two components will be stored, the date and the information, and the data stored is private, ensuring that no other applications can read the user’s personal diary. This is completed in the DiaryActivity, a java activity, with the diary_activity.xml layout.

The last standard functionality would allow the user to enter a date they would like to search and it will be searched on Google to see if any major events that have happened on that day. This will use the same EditText as the bonus functionality for creating markers on the locations on Google Maps. By clicking on the button “Search Date”, an implicit intent of ActionView will be called in the MainActivity class.

Bonus Functionality

The basic functionality allows data to be retrieved from the SQLite database and display it in a RecyclerView. The bonus functionality will split the string of data retrieved from the query method and the longitude and the latitude will be placed in an array, taking place in the MapActivity class. The array will allow the creation of multiple markers which will be placed on the google maps. The result will be a visually pleasing display of data. This is done with the Maps Fragment. I have also added a dialog box to tell the user what this application is about.

3 activities
Figure 3: This diagram shows 3 of the four activities. Using Android Studio, I have used default GPS coordinates which points to Northern Canada.

Activities

The main activity will be a menu page where the user can select the functions they wish. The second activity is the SQLite Database data which is displayed in a recycler view. The user can click on one item and it will be displayed on a map. The third activity is the diary activity which allows the user to write what they have done for one day and save it using shared preferences. The fourth activity opens the google maps activity which allows the coordinates to be displayed visually with markers.

Challenges

Aside from splitting the string from the SQLite Database and only keeping the longitude and latitude which will be placed in an array for creating multiple markers, the hardest part will definitely be creating the GPS service and allow the information to be stored into the SQLite Database. The only way for me to solve this is to break this task into two parts, creating the GPS Service and then storing it into the SQLite Database. After searching for multiple tutorials online on GPS and trying several, I managed to get it working. In addition, I have also noticed that the API key was set for one project and it will only run on my desktop computer. In order to prevent this from happening, I went online and changed the settings to any application can use my API key.

Download File

Completed Application using Android Studio ZIP

Once downloaded, you may unzip and open the file in Android Studio to install the application on your phone.