private Location getLastKnownLocation() {
List<String> providers = mLocationManager.getProviders(true);
Location bestLocation = null;
for (String provider : providers) {
Location location = mLocationManager.getLastKnownLocation(provider);
ALog.d("last known location, provider: %s, location: %s", provider, location);
if (location== null) {
continue;
}
if (bestLocation == null
|| location.getAccuracy() < bestLocation.getAccuracy()) {
ALog.d("found best last known location: %s", location);
bestLocation = location;
}
}
if (bestLocation == null) {
return null;
}
return bestLocation;
}
Android GPS Location null
最新推荐文章于 2021-05-27 11:21:14 发布