I was wondering how to correctly use the Location.distanceBetween method in Java to get the distance through multiple points.
Say you have a latitudeList and longitudeList, and you’d use a for=loop through them, how to use that method (effectively)?
I seem to get the wrong distance value.
The code I’m using currently (it’s messy but it seemed allright):
float result = 0;
float[] resultList = new float[1];
for (int k = 0; k < latitudeList.size() - 1; k++)
{
Location.distanceBetween(latitudeList.get(k), longitudeList.get(k), latitudeList.get(k+1), longitudeList.get(k + 1), resultList);
result = result + resultList[0];
resultList = new float[1];
}
What did I do wrong?
Thank you for your help.
why are you doing???
while your distance is in resultList[0].
modify your code like this