private Location getLastKnownLocation(LocationManager locationManager) {
List<String> providers = locationManager.getProviders(true);
Location bestLocation = null;
for (String provider : providers) {
Location l = locationManager.getLastKnownLocation(provider);
if (l == null) {
continue;
}
if (bestLocation == null || l.getAccuracy() < bestLocation.getAccuracy()) {
// Found best last known location: %s", l);
bestLocation = l;
}
}
return bestLocation;
}
解决室内 locationManager.getLastKnownLocation 为null
最新推荐文章于 2025-05-12 16:59:32 发布