get Distance from latitude and longitude - Android android.location

Android examples for android.location:Location

Description

get Distance from latitude and longitude

Demo Code

import android.content.Context;
import android.location.Location;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main{

    public static double getDistance(double lat1, double lon1, double lat2,
            double lon2) {
        float[] results = new float[1];
        Location.distanceBetween(lat1, lon1, lat2, lon2, results);
        return results[0];
    }//  w  ww. jav  a  2s . c om

}

Related Tutorials