Chris Pollett > Students >

    ( Print View)




    [Deliverable 1: GPS App]

    [Deliverable 2: Image Feature Selection]

    [Deliverable 3: Accelerometer and Video Recording Apps]

    [Deliverable 4: Model Survey]

    [Deliverable 5: CS297 Report]

    [Menze Paper Review Slides]

    [Pomerleau Paper Review Slides]



Get Familiar with Android Studio and Test Water with Real-time GPS App


Since this thesis project collects and uses the raw data with users' cellphones, it calls for an App that is able to record the actual or analogous information on steering wheel movements and real time traffic condition, just to name a few. The first step to take toward this goal is to code and test some App's to realize some required functions separately before integrating them into a finalized App.

The App platform chosen here is Android Studio due to the fact that dominating amount of worldwide cellphones are powered by Android OS. The first test App to get familiar with Android Studio is GPS App. The source code was written with Android API 28, the latest version as of 2019. App uses LocationManager class and LocationListerner interface to obtain GNSS coordinates. LocationListerner requires the implementation of onLocationChanged(), onStatusChanged(), onProviderDisabled(), and onProviderEnabled() methods. onLocationChanged() is where the latitudes and longitude are obtained. Finally, permission to access fine and course locations is provided in manifest.

How to run the code:

Two ways: emulator or android smartphone tethering. I mainly used emulator and double checked with tethering. Both work well albeit slower implementation on emulator.

For emulator, choose any virtual cellphone that supports Android API 28 and click RUN on Android Studio. Emulator provides the GNSS coordinates: click on ... button and GPS information is listed on the top of left-handed bar.

For cellphone tethering, a Huawei MateSE is used for testing. To debug and run the code on the cellphone, two steps are required: 1)activating developer mode on the cellphone. Follow Setting > About phone > Build Number > click seven times, and you are in developer mode. To allow for debugging and testing, follow Setting > System > Developer Mode > Debugging > select USB debugging; 2) choose the tethering mode in Android Studio by following RUN > Edit Configurations... > Delopyment Target Options > USB Device.

Source code:

package com.example.gpss;
import android.content.Intent;
import android.location.LocationListener;
import android.os.Bundle;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;
import android.location.LocationProvider;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements LocationListener {

    private LocationManager mlocationManager;
    private TextView mLatitude, mLongitude;
    private Location location;

    public void onCreate(Bundle savedInstanceState) {
        mlocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        mLatitude = (TextView) findViewById(;
        mLongitude = (TextView) findViewById(;
        location = mlocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        catch(SecurityException se){

    protected void onResume()
         * Add LocationListener and request updates every 1000ms or 10m
         * Notice in this case we are saying this Activity implements LocationListener
         * requestLocationUpdates asks explicit permission or throw Security Exception
        try {
                    LocationManager.GPS_PROVIDER, 1000, 10f, this);
        catch(SecurityException se){
    protected void onPause()

    public void onProviderDisabled(String provider)
        Log.v("GPS", "Disabled");
        Intent intent = new Intent(

    public void onProviderEnabled(String provider)
        Log.v("GPS", "Enabled");

    public void onStatusChanged(String provider, int status, Bundle extras)
        switch (status)
            case LocationProvider.OUT_OF_SERVICE:
                Log.v("GPS", "Status Changed: Out of Service");

            case LocationProvider.TEMPORARILY_UNAVAILABLE:
                Log.v("GPS", "Status Changed: Temporarily Unavailable");
            case LocationProvider.AVAILABLE:
                Log.v("GPS", "Status Changed: Available");

    public void onLocationChanged(Location location){
        Log.v("Current Latitude:" , ""+location.getLatitude());
        Log.v("Current Longitude:" , ""+location.getLongitude());

Emulator Screenshot: