我想将 LocationResult 类对象转换为 Location 类对象。这样我就可以访问 Location 类中的所有方法。
protected void onHandleIntent(Intent intent) {
if(LocationResult.hasResult(intent)){
LocationResult currentLocation = com.google.android.gms.location.LocationResult.extractResult(intent);
calculateDistanceTo(currentLocation);
return;
}
}
最佳答案
如果您阅读文档:https://developers.google.com/android/reference/com/google/android/gms/location/LocationResult
您会发现无法将 LocationResult
转换为 Location
,因为 LocationResult
有一个 Location
列表。
应用getLocations()
并循环遍历每个Location
来执行您想要的操作。
关于java - 如何将Android中的LocationResult类转换为Location类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42762868/