The goal of this lab is to make the ITU ActivityTracker system. It is a system that tracks location and movement data from a user’s mobile phone, and sends all of this to a server in the cloud. From this server, the mobile phone can then get the activity level of a user on a per day basis.

This lab consists of 5 main parts:

  • Remind yourself on how to obtain location data on the Android phone from Lab Class #3.
  • Show location information on the Android Phone using the Google Map component.
  • Store user location information in the Cloud (Google App Engine).
  • Sampel activity (movement) data on the phone and store this too.
  • Consider power management in this system.

Preparation

Before coming to class you should;

Part I - SkyHook & Location on Android

This this exercise, you should create a simple Android app that uses the SkyHook API to get the location. Implement the code snippet on the SkyHook Android API page and print out the obtained location on the a simple console. Deploy the app on an Android phone, and test it. Note that SkyHook does not work in the simulator, so you have to deploy it in order to test it. Try moving outside of ITU also.

If you are in the mood, try to extend the app using the build-in Android Location API. You can print out both location estimates side by side and try to compare what the two technologies.

Part II - Google Map

To make it easier for you to add powerful mapping capabilities to your application, the Google APIs add-on includes a Maps external library, com.google.android.maps. The classes of the Maps library offer built-in downloading, rendering, and caching of Maps tiles, as well as a variety of display options and controls.

Take a look at the Hello, MapView Tutorial and use this to add a map to your application. For now, this map should be able to show you own location.

Part III - Cloud Computing

Now, create a Google App Engine Project for storing location information in the cloud, like described in this tutorial. You can name this project “Activitytracker” and package name dk.itu.activitytracker.

This application should store information about a user’s activity, which basically means;

  • a history of movement for a day as obtained by location updates on the phone
  • physical activity for a day as measured by the accelerometer on the phone

The aim is to provide the user with an overview of how much he has physically moved around and his level of activity. The measures are movement in kilometers and physical movement.

Data is to be stored and fetched from the App Engine DataStore.

In order to handle users, you may want to look at the built-in Users Service in the App Engine. But for this prototype you should not use it. Instead just use a simpel text string as a username, and hard-code this user name in the Android phone.

Now;

  • Write a Google App Engine Servlet that takes data on location and accelerometer data from a HTTP POST from a client, and stores this data in the DataStore
  • Rewrite the Android app above to post location data to this servlet.
  • Write a servlet that can provide location and activity data for a user for a specific day.
  • Add an Activity to the Android app that can get and show location and activity data for the user for a day. You can do this is two ways; either (i) show a trace of the persons movement on the map, and some additional information about the accelerometer data in an overlay, or (ii) do the math of calculating the travel distance and show this in a simple table. If you are making a table, you should be able to show data for the last 7 days

Part IV - Activity Detection

So far, the Android app is not samling activity data and we need to add that. Extend the Android app to sample activity data and submit this to the cloud also. You should use the SensorManager class, which lets you access the device’s sensors. Get an instance of this class by calling Context.getSystemService() with the argument SENSOR_SERVICE.

Part V - Power Management

This system we have just created can potentially consume a lot of power and energy on the phone. If you’re not cautious, you will drain a fully charged battery in hours! You should consider what you can do in order to save energy on the phone. You may want to consider things like;

  • sampling rate of location and accelerometer data
  • when to turn sensors (like GPS, accelerometer, WIFI, etc.) on and off
  • how to transmit data to and from the cloud
  • feedback on energy usage to the user

You should pick at least on energy conserving strategy and implement this.

Tips and tricks:

  • Be aware that updating UI elements on Android should happen from the main thread. If you run SkyHook tracking in a separate thread, use the Handler-class to handle UI updates on callbacks.
  • You will want to upload your Google App to the Google server, but if you want to test communication between the app and your Android app on your own computer, remember to run the app with your IP address as argument (–address=your.ip.address)
  • To calculate the Euclidean distance between to points (lat,lon) you can use the following conversion: 1 lat degree ~ 111335.58 meters, 1 lon degree ~62940.42 meters.

7 Responses to “Lab Class #10 - The ITU ActivityTracker System”


  1. 1 jhgi April 19, 2012 at 18:37

    When I try to follow step 3 here: https://developers.google.com/appengine/docs/java/tools/eclipse?hl=da-DK, I eventually get the following error message:

    An error occurred while collecting items to be installed
    session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
    Unable to read repository at http://dl.google.com/eclipse/plugin/3.7/plugins/com.google.appengine.eclipse.core_2.5.2.v201203300216-rel-r37.jar.
    Read timed out
    Unable to read repository at http://dl.google.com/eclipse/plugin/3.7/plugins/com.google.appengine.eclipse.sdkbundle_1.6.4.v201203300216r37.jar.
    Read timed out
    Unable to read repository at http://dl.google.com/eclipse/plugin/3.7/plugins/com.google.gdt.eclipse.core_2.5.2.v201203300216-rel-r37.jar.
    Read timed out
    Unable to read repository at http://dl.google.com/eclipse/plugin/3.7/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37.jar.
    Read timed out

    I’m trying to get the Plug In for Eclipse 3.7, is there anything I can do about the error?

  2. 2 jhgi April 19, 2012 at 19:25

    When I try to install the SDKs, I get the following error:

    An error occurred while collecting items to be installed
    session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
    Unable to read repository at http://dl.google.com/eclipse/plugin/3.7/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37.jar.
    Read timed out

    Can anything be done to solve it?

  3. 3 jhgi April 19, 2012 at 19:26

    And in case anyone is wondering about the double post, only now I can see that my first post is waiting for moderation.

  4. 4 Egil Hansen April 20, 2012 at 12:44

    Are you running Java 7.x? I have had problems before with GWT and GAE and Java 7. Basically it is not supported.

  5. 5 jhgi April 20, 2012 at 13:21

    I have found a solution that seems to work.

    Download this file, and use the archieve to install the files that you want in Eclipse:

    http://dl.google.com/eclipse/plugin/3.7/zips/gpe-e37-latest-updatesite.zip

  1. 1 Hi Dude Trackback on March 21, 2013 at 09:50
  2. 2 add followers on twitter Trackback on March 22, 2013 at 08:55

Leave a Reply

You must login to post a comment.