Service not found using its component name
I'm stuck with a service, which can't be found using it's explicit component name in the starting intent sent by startService(). The classes are in the same project and package. The explicit service calling with its component name is intentional, because it's supposed to be a private service, and the startService/stopService method instead of the bindService is intentional too, because the service should run in the background without any activity communicating with it. Must be a stupid mistake, but I spent 2 days looking for it and no luck yet. I have an other project too, which uses the same service calling method and it works, compared the two multiple times, but no real difference. What can I be possibly be doing wrong?
//main act开发者_如何学编程ivity which controls the service
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
Intent intent = new Intent(this, Logger01Service.class);
startService(intent);
//...
}
The error in the debugger's log:
11-23 11:07:28.711: WARN/ActivityManager(1279): Unable to start service Intent { cmp=com.biroalex.test.logger/.LoggerService }: not found
What can I be possibly be doing wrong?
Have you declared it in the AndroidManifest.xml?
from http://developer.android.com/reference/android/app/Service.html :
Each service class must have a corresponding declaration in its package's AndroidManifest.xml
You have to make an entry in AndroidManifest.xml about your each Activity or Service. I think you are missing this. Check it out.
Example from API DEMO manifest file:
<service android:name=".app.ForegroundService" />
精彩评论