Android ContentProvider with Services
android, android-contentprovider, android-service
Solution
I binded the service in the onCreate() method
@Override
public boolean onCreate() {
mContext = getContext();
.. do other things
doBindService();
return true;
}
and then used the context to actually bind the service
void doBindService() {
mContext.bindService(new Intent(mContext,
SomeService.class), mConnection, Context.BIND_AUTO_CREATE);
}
I don't unbind from the service, but it seems to work ok
Problem
I have a ContentProvider subclass doing all my database work, and a Service that is running in the background. I can't seem to be able to bind a Service to the ContentProvider. Can I call a method from the service within the ContentProvider at all, or is there a way to bind?