0

我正在使用 GCM 发送通知,一切正常。我尝试创建一个 GCM 库,这样我就可以轻松地将 GCM 集成到我未来的 Android 应用程序中。我创建了一个项目,其中包含显示通知所需的所有内容,并将其标记为库。当我执行应用程序时,它会获取注册 ID,一切似乎都正常,但没有显示任何通知。

使用过滤器Tag:GCMLogCat得到以下信息:

04-29 15:24:33.937: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.REGISTRATION
04-29 15:24:33.937: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:33.937: V/GCMBaseIntentService(19334): Acquiring wakelock
04-29 15:24:44.195: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.RECEIVE
04-29 15:24:44.195: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:44.195: V/GCMBaseIntentService(19334): Acquiring wakelock
04-29 15:24:44.242: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.RECEIVE
04-29 15:24:44.242: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:44.242: V/GCMBaseIntentService(19334): Acquiring wakelock
04-29 15:24:44.320: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.RECEIVE
04-29 15:24:44.320: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:44.320: V/GCMBaseIntentService(19334): Acquiring wakelock
04-29 15:24:44.398: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.RECEIVE
04-29 15:24:44.398: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:44.398: V/GCMBaseIntentService(19334): Acquiring wakelock
04-29 15:24:44.453: V/GCMBroadcastReceiver(19334): onReceive: com.google.android.c2dm.intent.RECEIVE
04-29 15:24:44.460: V/GCMBroadcastReceiver(19334): GCM IntentService class: com.mobiblanc.slice.GCMIntentService
04-29 15:24:44.460: V/GCMBaseIntentService(19334): Acquiring wakelock

PS:当我以简单的方式使用 GCM 时,我在 Logcat 中有更多的行,例如:releasewakelock Thanks

4

1 回答 1

0

奇怪,但这里给出的解决方案对我有用。仔细检查您的清单文件并验证广播接收器/意图服务标签和实际服务类名称是否匹配。最后尝试将 GCM 意图服务类及其父活动放在同一个包中。

于 2013-05-16T07:11:17.770 回答