是什么导致"无法启动服务意图"?

时间:2011-08-11 20:35:20

标签: android

我的应用程序收到来自C2DM服务器的意图以注册推送通知(工作正常),并且在通过广播接收器接收该消息时,它启动IntentService(以处理从C2DM接收的意图)。但是,启动IntentService的调用失败了:

Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION
cat=[com.company.myapp] cmp=com.company.myapp/.receiver.C2DMReceiver
(has extras) }: not found

你能帮我理解一下这个错误是什么意思吗? C2DMReceiver类是IntentService的子类,它肯定存在。我正在使用Intent.setClass()并直接指定该类。编译器接受它,所以我不明白为什么异常说“未找到”。什么没找到?

如果有人可以提供有关调试的任何提示,我真的很感激。

    <receiver android:name="com.company.myapp.receiver.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <!-- Receive the actual message -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.company.myapp" />
        </intent-filter>
        <!-- Receive the registration id -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.company.myapp" />
        </intent-filter>
    </receiver>

3 个答案:

答案 0 :(得分:1)

原因是清单中缺少标签。不幸的是,我似乎意外地从清单中删除了它,可能是在进行另一次编辑时。使用那里的清单条目,IntentService就可以正常运行了。

答案 1 :(得分:0)

您是否在AndroidManifest.xml中注册了具有操作com.google.android.c2dm.intent.REGISTRATION的Intent过滤器?

答案 2 :(得分:0)

您必须拥有安装了Android 2.2+和Market app的设备(这意味着它是官方Google设备)。