title: How the OLA and UBER calculating the distance for their billing
body: <p>I want to develop a small app that calculates the distance while traveling.
  I have tried the solution below, based on the GPS of Android, but the result is wrong.</p>
  
  <p>Please help me on this</p>
  
  <p>My code: </p>
  
  <pre><code>locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 10, this);
    public void onLocationChanged(Location location) {
  
      if ((location != null)) {
          if (location.getAccuracy()&lt;50 &amp;&amp; location.getSpeed()&gt;0) {
              onlocationChangeMethod(location);
              lastlatitude = location.getLatitude();
              lastlongitude = location.getLongitude();
  
          }
  
      }
  }
  public void onlocationChangeMethod(Location location){
      if (lastlatitude &gt; 0 ) {
              float[] results = new float[5];
              location.distanceBetween(location.getLatitude(), location.getLongitude(),
                      lastlatitude, lastlongitude, results);
      }
  }
  </code></pre>