简体   繁体   中英

How to continuously calculate distance between location updates to get a total distance

How to continuously calculate distance between location updates to get a total distance . I tried to capture coordinate at time t-1 (previous location) and at time t (current location) by using listview but couldn't get good results. I have searched all over the internet and the solution I found so far is to calculate distance between two points. In my question, there will be a series of location updates resulting in list of coordinates. Please kindly help.

@Override
    public void onLocationChanged(Location location) {
        if (location !=null)
        {
            Lat=location.getLatitude();
            Long=location.getLongitude();
            
    // How to continuously calculate distance between location updates to finally get the total distance when I stop location update

        }else{
            Toast.makeText(getActivity(), "No location update", Toast.LENGTH_LONG).show();
        }
    }

我返回总距离的位置为我提供了所需的结果。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM