onRegistered 方法永远不会被调用,在 logcat 中我看到最后一行正在获取唤醒锁。
- 09-26 14:03:23.285: D/GCMRegistrar(15820): 重置退避
- 09-26 14:03:23.285: V/GCMRegistrar(15820): 注册应用程序 *a of senders 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): 获取唤醒锁
我有自己的广播接收器:
import com.google.android.gcm.GCMBroadcastReceiver;
public class MyGCMBroadcastReceiver extends GCMBroadcastReceiver {
@Override
protected String getGCMIntentServiceClassName (Context context) {
return GCMIntentService.class.getCanonicalName();
}
}