title: Get the distance between two locations in android?
body: <p>i need to get distance between two location, but i need to get distance like blue line in the picture.
  <img src="https://i.stack.imgur.com/Vu3FJ.png" alt="picure"></p>
  
  <p>I try next:</p>
  
  <pre><code>public double getDistance(LatLng LatLng1, LatLng LatLng2) {
      double distance = 0;
      Location locationA = new Location("A");
      locationA.setLatitude(LatLng1.latitude);
      locationA.setLongitude(LatLng1.longitude);
      Location locationB = new Location("B");
      locationB.setLatitude(LatLng2.latitude);
      locationB.setLongitude(LatLng2.longitude);
      distance = locationA.distanceTo(locationB);
  
      return distance;
  }
  </code></pre>
  
  <p>but i get red line distance.</p>