title: how to calculate distance travelled
body: <p>I am developing an application in which I need to calculate the distance travelled. I am facing a problem while calculating the distance.
  Here is my code:</p>
  
  <pre><code> locationmanager.requestLocationUpdates(bestProvider,0,0,new Listener());
  
   public class Listener implements LocationListener{
  
  @Override
  public void onLocationChanged(Location location) {
      if(location!=null) {
          if(loc1==null) {
              loc1=new Location(location);
          }
  
          speed=location.getSpeed()*3.6;
          loc2=new Location(location);
          dist+=loc1.distanceTo(loc2);
          loc1=loc2;
          breaktv.setText(""+dist/1000);
  </code></pre>
  
  <p>My intention is calculate the total distance travelled by car or something. But <code>distanceTo()</code> method is not working well for me.</p>