我在 LogCat 中遇到了这个异常:
Unable to start service Intent { cmp=com.thePackage.me/com.thePackage.c2dm.RegistrationService (has extras) }: not found
这是由IntentService
. 现在为了测试我只是发出一条日志消息
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);
}
}
我BroadcastReciever
以这种方式从 a 开始这项服务
Intent serviceIntent = new Intent(context, RegistrationService.class);
serviceIntent.putExtra("REG_ID", reg_Id);
serviceIntent.putExtra("DEVICE ID", manager.getDeviceId());
context.startService(serviceIntent);
为什么会产生这个异常?我必须在 中声明Manifest
吗?