Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM onRegistered not called

The onRegistered method never gets called, in the logcat I see the last line as acquiring wakelock.

  • 09-26 14:03:23.285: D/GCMRegistrar(15820): resetting backoff for
  • 09-26 14:03:23.285: V/GCMRegistrar(15820): Registering app *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): Setting the name of retry receiver class to *.notifications.MyGCMBroadcastReceiver
  • 09-26 14:03:23.895: V/GCMBroadcastReceiver(15820): GCM IntentService class: - *.notifications.GCMIntentService
  • 09-26 14:03:23.903: V/GCMBaseIntentService(15820): Acquiring wakelock

I have my own Broadcastreceiver:

import com.google.android.gcm.GCMBroadcastReceiver;

public class MyGCMBroadcastReceiver extends GCMBroadcastReceiver {

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

}
like image 375
user1270175 Avatar asked Sep 26 '12 22:09

user1270175


2 Answers

I had similiar problem. It turned out that I forgot to add to ApplicationManifest.xml:

<service android:name=".GCMIntentService"/>
like image 123
joozek Avatar answered Sep 28 '22 05:09

joozek


Following are common solutions:

1) Name you service as "GCMIntentService"

2) Put your GCMIntentService in default package

3) before sending GCM register request call

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);

So that if there is any problem with your device or menifest it will tell you. 4) check permissions. Particularly check package mane in permissions. This is a nesty on, if you mess up with package name in permission, it will work for latest androids(Jelly Bean +) but will fail in lower devices

like image 32
ADKum Avatar answered Sep 28 '22 05:09

ADKum