title: Android Calculate Distance Traveled
body: <p>I am currently working on an application focused around fitness. The basic I idea is to allow to people to track their speed,distance,time. So far I have managed to get speed working by using location manager getSpeed(). I wanted to find out how I can get the distance traveled?
  I looked for some samples but was bit confusing for me as I just started to work with android.
  I would appreciate any help or advise , thanks</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_track);
  
      start = (Button) findViewById(R.id.btnStart);
      speed = (TextView)findViewById(R.id.txtSpeed);
      locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  
  
  
      //initialize location listener
      locationListener = new LocationListener() {
          @Override
          public void onLocationChanged(Location location) {
              getSpeed(location);
          }
  
          @Override
          public void onStatusChanged(String s, int i, Bundle bundle) {
  
          }
  
          @Override
          public void onProviderEnabled(String s) {
  
          }
  
          @Override
          public void onProviderDisabled(String s) {
  
          }
  
          //get the speed from the given location updates
          public void getSpeed(Location location) {
              currentSpeed = (location.getSpeed()*3600/1000);
              String convertedSpeed = String.format("%.2f",currentSpeed);
              speed.setText(convertedSpeed + "Km/h");
          }
  
          public void getDistance(Location location){
  
          }
  
      };
  </code></pre>