Code example for Location

Methods: getAccuracygetLatitudegetLongitudehasAccuracy

0
     */ 
    LocationListener locationListenerGps = new LocationListener() {
        public void onLocationChanged(Location loc) { 
            if (DEBUG) Log.d(TAG, "GPS location listener being utilized"); 
            if ((location.getProvider().equals(DEFAULT_PROVIDER)) || (!location.hasAccuracy())) { 
                location = loc; 
                // send location update broadcast 
                Intent intent = new Intent(); 
                intent.setAction(LOCATION_UPDATE_INTENT); 
                intent.putExtra("latitude", loc.getLatitude()); 
                intent.putExtra("longitude", loc.getLongitude()); 
                sendBroadcast(intent); 
            } 
            else if	((loc.hasAccuracy() && (loc.getAccuracy() < location.getAccuracy())) || 
                    ((location.distanceTo(loc) > MAX_DISTANCE_METERS)) 
                            && (loc.hasAccuracy()) 
                            && (loc.getAccuracy() < location.distanceTo(loc))) { 
                location = loc; 
                // send location update broadcast 
                Intent intent = new Intent(); 
                intent.setAction(LOCATION_UPDATE_INTENT); 
                intent.putExtra("latitude", loc.getLatitude()); 
                intent.putExtra("longitude", loc.getLongitude()); 
                sendBroadcast(intent); 
            } 
        } 
        public void onProviderDisabled(String provider) { 
            // notify listeners that gps has been disabled