The Android App

In this assignment, you will learn how to create an application using the Android OS. The application will place pins on a map at the spots that you last saw your friends. The application UI will be simple and consist only of a list of your friends and the map (with pins representing your friend's location). When you see your friend you simply click their name and the application places a pin on the map at your current location. The entire application will function within a device emulator that is packaged with the android SDK.

UPDATES

Android Development Environment

Before you can begin writing your first android application you need to configure your environment. In order to configure your environment you will need to follow the Getting Started Guide. While going through the entire guide would be useful the most important parts are the first four sections ("Installing..." through "Autonomy...").

The next step is to create the eclipse project that will contain your assignment. Follow the steps provided in the "Hello Android" documentation but use the following values...

Now we have provided you with some helper classes and configuration files to make the assignment easier. Please copy the following files into the specified directories.

Finally you need to include the following XML snippets in the AndroidManifest.xml, which is at the root of the project. After opening the file in eclipse, place the following lines in the specified locations in the XML.

Part 1: Listing your Contacts

To make this worthwhile you will first need to add some friends to your emulator's contact manager. To do this you will need to start the emulator. You can do this by telling eclipse to run your application. After starting your application follow these steps...

  1. Click on the home button on the device. This should bring you to the "desktop" of the phone.
  2. Open the "Contacts" application.
  3. From the contacts menu click on the menu button on the device. Click on the "new contact" option.
  4. In the top box set the first and last name to "Andy Allen", then scroll to the bottom and click save.
  5. Repeat steps 3 and 4 for the following names...
  6. You should now have 8 contacts stored in the emulator. These contacts will remain in the emulator even after rebooting so you shouldn't need to do this step again.

Android uses a service-oriented architecture by making most of the phone's features available via ContentProviders. We will use the existing "Contacts" content provider to programatically get a list of all of your friends. Information on how to retrieve data from a content provider can be found in this document. You will add your code to the FriendViewAdaptor.java file and upon success you will see the contacts listed at the top portion of the application.

Part 2: Get GPS Location

To help you along we have provided a class called GPSWrapper which has only one static method. Calling this method will return random GPS coordinates around Centennial campus. This class allows you to emulate getting GPS data from the devices built-in GPS sensor. When testing this with a real device, you can replace the logic in this class with code that retrieves data from the sensor. Fortunately, this is outside the scope of this assignment, so you can leave the GPSWrapper class as is.

Part 3: Put Friend's Location on Map

The final portion of the project is placing a marker on the map at the location where you last saw your friend. To assist in this process we have provided the FriendsMapOverlay class. Before we make use of this class we must first get the map to display within our application to do this we need to generate an Maps API key. To generate the key you must...

  1. Follow the instructions found here (Getting the MD5 Fingerprint of the SDK Debug Certificate) to generate the fingerprint. The keytool application should be in your path if the Java SDK is in your path. If not, then find the location of the SDK on your computer go to the bin directory and you should find the keytool program there.
  2. Follow the instructions found here (Registering the Certificate Fingerprint with the Google Maps Service) to generate the Maps API key. You will need a valid google account to complete this step.
  3. Using the key acquired in the previous step, open the res/layout/friend_map.xml and find the MapView element. Replace the placeholder [put key here] text within that element with the API key.
  4. Restart your application and you should see a map of NCSU's Centennial campus in the bottom portion of the application UI.

Now that you have a map all we need to do is put markers on the map when you click one of your friends names. The code to recognize when a name is clicked has been provided and results in the execution of the method addMarkerAtCurrentLocation(String markerName) in FriendMapper.java. It is your responsibility to complete this method to ensure the follow happens...

Deliverables