问题
I verified that the app can receive notifications on galaxy nexus tablet (4.2)and samsung galaxy s3 phone(4.1.1), but cannot work on samsung galaxy tab 10.1 (4.0.4) and samsung 7 inch tablet(4.0.4)
There is more than one google account signed in to the tablet. I received the registration ID, and while I send the notifications I get the error
Error log,
05-22 14:40:47.220: W/GTalkService(10357): [DataMsgMgr] broadcast
intent callback: result=CANCELLED forIntent {
act=com.google.android.c2dm.intent.RECEIVE cat=[ xxx ] (has extras) }
05-22 14:40:47.225: W/GTalkService(10357): Receiver package not found,
unregister application com.myapp.example sender
Android manifest has all the necessary permissions
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Only this application can receive the messages and registration result -->
<permission android:name="com.myapp.example.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.example.permission.C2D_MESSAGE" />
<receiver
android:name="com.myapp.example.gcm.GCMReceiver"
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.myapp.example.gcm" />
</intent-filter>
</receiver>
<service android:name=".gcm.GCMService" />
回答1:
It started working after I modified the category in the receiver,
from
<category android:name="com.myapp.example.gcm" />
to
<category android:name="com.myapp.example" />
来源:https://stackoverflow.com/questions/16702172/gcm-doesnt-work-on-samsung-tablets