Im currently doing an apps that can track running distance.
My idea is when i click start, i will record the position that i start running, then when i click stop, it will record the position that i end my running. Then calculate the distance between this 2 point. 
I don't know why my distance result din show anything. Please help me see if gt any problems~

package com.example.ifitness;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.SupportMapFragment;

import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class calorieburn extends ActionBarActivity implements LocationListener{
private GoogleMap map;
private Location newlocation;
private double latA;
private double longA;
private double latB;
private double longB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.calorieburn);
        SetupMap();           
        
        Button start = (Button) findViewById(R.id.start);
        
        start.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
 
 latA = newlocation.getLatitude();
 longA = newlocation.getLongitude();
 
}
});

        
        Button stop = (Button) findViewById(R.id.stop);
        
        stop.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub


 
 latB = newlocation.getLatitude();
 longB = newlocation.getLongitude();

 TextView distance = (TextView) findViewById(R.id.distance);
 distance.setText(String.valueOf(distance(latA,longA,latB,longB)+ "km"));
 

}
});             

 }


    
    public double distance(double lat,double lng,double latitude,double longtitude){
    Location locA = new Location("locA");
locA.setLatitude(lat);
double l1=Math.toRadians(lat);
locA.setLongitude(lng);
double g1=Math.toRadians(lng);

Location locB = new Location("locB");
locB.setLatitude(latitude);
double l2=Math.toRadians(latitude);
locB.setLongitude(longtitude);
double g2=Math.toRadians(longtitude);

double distance = Math.acos(Math.sin(l1) * Math.sin(l2) + Math.cos(l1) * Math.cos(l2) * Math.cos(g1 - g2));
   if(distance < 0) {
       distance = distance + Math.PI;
   }

  Math.round(distance * 6378100);
  
  if(distance<=0)
  return distance = 0;
  else 
  return distance;

//double distance = locA.distanceTo(locB)/1000;

    }

    
private void SetupMap() {
if (map == null){
    // Getting reference to the SupportMapFragment of activity_main.xml
    SupportMapFragment mf = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
       
    // get google map from the fragment
    map = mf.getMap();                            
    }
   
    if (map !=null ){
   
    // Enabling MyLocation Layer of Google Map
    map.setMyLocationEnabled(true);
   
    // Getting LocationManager object from System Service LOCATION_SERVICE
    LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
   
    String provider = LocationManager.NETWORK_PROVIDER;
   
    if (provider == null){
    onProviderDisabled(provider);
    }
   
    // Getting Current Location
    Location loc = lm.getLastKnownLocation(provider);
    if (loc != null){
    onLocationChanged(loc);
    newlocation = loc;
    }
   
    map.setOnMapLongClickListener(onLongClickMapSettings());
    }
  }

private OnMapLongClickListener onLongClickMapSettings() {
// TODO Auto-generated method stub
return new OnMapLongClickListener(){

@Override
public void onMapLongClick(LatLng arg0) {
// TODO Auto-generated method stub
Log.i(arg0.toString(), "User Long CLicked");
}
};
}

@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub

// Getting latitude of the current location
        double latitude = location.getLatitude();
 
        // Getting longitude of the current location
        double longitude = location.getLongitude();
 
        // Creating a LatLng object for the current location
        LatLng latLng = new LatLng(latitude, longitude);
 
        // Showing the current location in Google Map
        map.moveCamera(CameraUpdateFactory.newLatLng(latLng));
 
        // Zoom in the Google Map
        map.animateCamera(CameraUpdateFactory.zoomTo(17));

}

private void makeUseOfNewLocation(Location location) {
// TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub

}


}