IntentService Not found
-
27-05-2021 - |
Question
I am getting this exception in the LogCat:
Unable to start service Intent { cmp=com.thePackage.me/com.thePackage.c2dm.RegistrationService (has extras) }: not found
Here is by IntentService
. Right now for testing I am just issuing a log message
public class RegistrationService extends IntentService {
public RegistrationService(){
super("NAME");
}
public RegistrationService(String name) {
super(name);
}
@Override
protected void onHandleIntent(Intent intent) {
Log.d("RegistrationService", "onHandleIntent INVOKED");
System.out.println(intent.getDataString());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
System.out.println(intent.getDataString());
return super.onStartCommand(intent, flags, startId);
}
}
I am starting this service from a BroadcastReciever
in this manner
Intent serviceIntent = new Intent(context, RegistrationService.class);
serviceIntent.putExtra("REG_ID", reg_Id);
serviceIntent.putExtra("DEVICE ID", manager.getDeviceId());
context.startService(serviceIntent);
Why is this exception being generated? Do I have to declare this in the Manifest
?
Solution
Correct, you have to declare the service in your Manifest file, even if it's not in your application namespace. If, for instance, we want to use the Urban Airship Push service, we have to declare it:
<service android:name="com.urbanairship.push.PushService" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow