0

我在 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吗?

4

1 回答 1

0

正确,您必须在您的清单文件中声明该服务,即使它不在您的应用程序命名空间中。例如,如果我们想使用 Urban Airship Push 服务,我们必须声明它:

<service android:name="com.urbanairship.push.PushService" />
于 2012-03-28T07:33:20.970 回答