I still have problem with fetching first location on android. I am using Criteria like
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setSpeedRequired(true);
String provider = lm.getBestProvider(criteria, true);
if(provider!=null && provider.length()>0){
lm.requestLocationUpdates(provider, 0, 0, this);
}
I need to stop when first time get location like lm.removeUpdates(this);
Where to put that line of code ? In onLocationChanged ?
1 Answer