Green goblin
Green goblin

Reputation: 9996

Stop Location Updates after first time

I am using a service which implements LocationListener class.Now i want to know the current location(Latitude,Longitude) of the device. I have used requestLocationUpdates method so that onLocationChanged method gets called when the location changes. I want that onLocationChanged method should be called only once i.e. when i get the location for the first time, it should not be called again. I have called stopSelf method to stop the service inside onLocationChanged method. But still i am getting location updates. Please help me.

Upvotes: 0

Views: 1764

Answers (1)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132982

Call removeUpdates on LocationManager, passing your location listener.

mLocationManager.removeUpdates(mListener);

Upvotes: 5

Related Questions