You don't need to bind to it in order to stop it. Wherever you have a Context
reference (Activity
, Service
or base application context) just call stopService()
:
private void stopServiceUsingContext(Context context) {
context.stopService(new Intent(context, MyServiceClass.class));
}
EDIT: If you want to stop the service in response to a preference change listener, then you should have a reference to an Activity
which extends Context
so above code applies