I have a problem with GCM on Android. It cannot call the onRegistered() or ever return a good regId on one of my test devices (Droid2), but it works fine on the other device (Galaxy Nexus).
I follow the basic example here . The caller is as follows:
GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) GCMRegistrar.register(this, Constants.SENDER_ID); else Log.v(TAG, "Already registered");
And my manifest has this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
and
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.gcl.myapp" /> </intent-filter> </receiver>
Why doesn't the onRegistered() callback work? And what can make it work on one device, but fail on another? Thanks.
source share