title: Calculate distance between two locations in metre
body: <p>I have two locations and I want to calculate distance in meter. I wrote some code but it's not working perfectly.</p>
  
  <pre><code>private void getDistanceBetweenTwoPoints(double lat1,double lon1,double lat2,double lon2)
  {
      Location loc1 = new Location("");
      loc1.setLatitude(lat1);
      loc1.setLongitude(lon1);
  
      Location loc2 = new Location("");
      loc2.setLatitude(lat2);
      loc2.setLongitude(lon2);
  
      int R = 6371; // km
  
      double dLat = deg2rad(lat2-lat1);
      double dLon = deg2rad(lon2-lon1);
      double  a =
              Math.sin(dLat/2) * Math.sin(dLat/2) +
                      Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
                              Math.sin(dLon/2) * Math.sin(dLon/2)
              ;
      double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
      double distanceInMeters = R * c;
      Log.e("distanceInMeters",distanceInMeters/10000+"mm");
  }
  
  public double  deg2rad(double deg) {
      return deg * (Math.PI/180);
  }
  </code></pre>
  
  <p>How can I calculate distance in meter? My goal is, if meter > 200 do something. How can i solve my problem?</p>