Deliverable #1

Description:

  • Deliverable 1 is about writing a test program in order to use GPS feature for our phone application. Currently the application is able to simulate the location within the emulator by sending in the coordinate with DDMS tool. In order to use the Google map, it is necessary to obtain a Maps API Key by getting the MD5 Fingerprint of my signing certificate, getting the MD5 fingerprint of the SDK debug certificate and then registering the certificate fingerprint with the Google Maps service.

My progress:

  • Done of write a test program to receive the DDMS tool simulated location and display the location within emulator.
  • Done of write a test program to display the location with Google map.
Issue:
  • Sign the application.
  • Obtain Google Maps API Key.
  • Download the application to the phone.

Source code


 package net.learn2develop;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class GPSMap extends MapActivity 
{    
    private LocationManager lm;
    private LocationListener locationListener;

    private MapView mapView;
    private MapController mc;
    
    


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	Log.d("onCreate", "testing in onCreate");
        super.onCreate(savedInstanceState);
        
 
        setContentView(R.layout.main); 
        
        //---use the LocationManager class to obtain GPS locations---
        lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);    
        
        locationListener = new MyLocationListener();
        
        lm.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            0, 
            0, 
            locationListener);
        
        mapView = (MapView) findViewById(R.id.mapview1);

         mc = mapView.getController();
         
         boolean on = true;

         Log.d("onCreate","setSatllite mode on = "+on);
         

    }
    public void onPause(){
    	
     lm.removeUpdates(locationListener);
     
     Log.d("onPause", "testing in onPause");
    	
    	
     super.onPause();
    
    }

    @Override
    protected boolean isRouteDisplayed() {
       
        return false;
    }        
    
    private class MyLocationListener implements LocationListener 
    {
        @Override
        public void onLocationChanged(Location loc) {
            if (loc != null) {                
                Toast.makeText(getBaseContext(), 
                    "Location changed : Lat: " + loc.getLatitude() + 
                    " Lng: " + loc.getLongitude(), 
                    Toast.LENGTH_SHORT).show();
                
                GeoPoint p = new GeoPoint(
                        (int) (loc.getLatitude() * 1E6), 
                        (int) (loc.getLongitude() * 1E6));
                mc.setCenter(p);
                mc.setZoom(16);  
                
                

            }
        }

        @Override
        public void onProviderDisabled(String provider) {
            Toast.makeText(getBaseContext(), 
                    "onProviderDisabled provider = " + provider,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onProviderEnabled(String provider) {
            Toast.makeText(getBaseContext(), 
                    "onProviderEnabled provider = " + provider,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            Toast.makeText(getBaseContext(), 
                    "onStatusChanged provider = " + provider
                    +"status = " + status,
                    Toast.LENGTH_SHORT).show();
        }
    }    
}