問題描述
尋找我和朋友之間最近的距離 (Finding nearest distance between me and friends)
我需要在 android.now 我有我的當前位置,我的意思是緯度、經度和朋友位置集找到最近的位置。我需要找到離我最近的朋友?誰能建議我如何在android中做到這一點?
參考解法
方法 1:
Use Location class. It has a method called distanceTo(Location loc)
to calculate the distance between two Locations.
Location myLocation = new Location("LocProvider");
myLocation.setLatitude(latitude);
myLocation.setLongitude(longitude);
//Same as above, Setup friendLocation
float distance = myLocation.distanceTo(friendLocation);
(by user3675519、balachandarkm)