I have a foreground service which implements LocationListener. When the Service is killed, it keeps on getting a fix. However this is what I call in the onDestroy()
@Override
public void onDestroy() {
Log.e(getPackageName(), "Destroying GPSservice");
super.onDestroy();
running = false;
stopForeground(true);
locationManager.removeUpdates(EventService.this);
locationManager = null;
}
Is there something I'm missing?
EDIT
More code. This is in the onCreate()
:
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String bestProvider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(bestProvider);
if (location != null) {
onLocationChanged(location);
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3000L, 15.0f, this);