I have a simple application that uses the Android system service LOCATION_SERVICE. On app close I need the service to stop. I have searched hard and long for how to do this but I must not be looking for the right thing. Does anybody know how to stop this service?
Here is what I'm doing.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
private LocationManager lm;
private LocationListener locationListener;
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
locationListener = new MyLocationListener();
lm.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0,
locationListener);
...
}
@Override
protected void onDestroy() {
lm.removeUpdates(locationListener);
super.onDestroy();
}
The LocationManager class does not seem to have any methods to stop the service. That's where I thought you would be able to close or stop it.
Thanks for any help.