-2

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();
        }
    }
At Line
  • 9
  • 1
  • "the solution I found so far is to calculate distance between two points": what else do you need? Isn't the sum of these distances exactly what you want? – Henry Sep 16 '20 at 14:52
  • _"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."_ What was wrong with the results? Maybe the calculation shouldn't be done too often as there's always a small inaccuracy in the location and in a small distance a small inaccuracy makes a significant error. (Like e.g. a 5 meter error in a 10 meter distance vs. 5 meter error in a 100 meter distance.) – Markus Kauppinen Sep 16 '20 at 14:54

1 Answers1

-1

The location where I return the total distance provided me the desired result.

At Line
  • 9
  • 1