Code example for Location

Methods: distanceTo

0
	private double distance = 0.0;
 
    @Override 
    public void onLocationChanged(Location location) {
        if (lastKnownLocation != null && location != null) {
            distance = lastKnownLocation.distanceTo(location);
            /* 
            HashMap<String, Double> m = new HashMap<String, Double>(); 
            m.put("distanceTraveled", distance);*/ 
            //FlurryAgent.logEvent("LocationChanged", m); 
            /*CharSequence text = "Location change with distance = " + distance; 
            Toast.makeText(context, text, Toast.LENGTH_LONG).show();*/ 
        } 
        lastKnownLocation = location;
    } 
 
    @Override 
    public void onProviderDisabled(String provider) {
        requestLocationUpdates(); 
    }