解决室内 locationManager.getLastKnownLocation 为null

private Location getLastKnownLocation(LocationManager locationManager) {
        List 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;
    }
 

你可能感兴趣的:(百度地图)