Я пытаюсь получить свое местоположение, используя это так:
LocationManager myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = myLocationManager.getBestProvider(criteria,true);
if (provider != null) {
//there is a provider
myLocationManager.requestLocationUpdates(provider, 10L, 500.0f, (LocationListener) mainContext);
Location myCurLocation = myLocationManager.getLastKnownLocation(provider);
//here i'm trying to get some data from the
//myCurLocation but
//myCurLocation == NULL
}
но myCurLocation всегда == NULL
Что я делаю не так?