GCM onRegistered未调用

use*_*175 7 android google-cloud-messaging

永远不会调用onRegistered方法,在logcat中我看到最后一行是获取唤醒锁.

  • 09-26 14:03:23.285:D/GCMRegistrar(15820):重置退避
  • 09-26 14:03:23.285:V/GCMRegistrar(15820):注册app*a发件人735175912799
  • 09-26 14:03:23.895:V/GCMBroadcastReceiver(15820):onReceive: - com.google.android.c2dm.intent.REGISTRATION 09-26 14:03:23.895:V/GCMRegistrar(15820):设置名称重试接收器类到*.notifications.MyGCMBroadcastReceiver
  • 09-26 14:03:23.895:V/GCMBroadcastReceiver(15820):GCM IntentService类: - *.notifications.GCMIntentService
  • 09-26 14:03:23.903:V/GCMBaseIntentService(15820):获取唤醒锁

我有自己的Broadcastreceiver:

import com.google.android.gcm.GCMBroadcastReceiver;

public class MyGCMBroadcastReceiver extends GCMBroadcastReceiver {

    @Override
    protected String getGCMIntentServiceClassName (Context context) {
        return GCMIntentService.class.getCanonicalName();
    }

}
Run Code Online (Sandbox Code Playgroud)

joo*_*zek 1

我有类似的问题。原来我忘记在ApplicationManifest.xml中添加:

<service android:name=".GCMIntentService"/>
Run Code Online (Sandbox Code Playgroud)