我正在尝试在我的应用程序中实现推送通知,但我的 C2DMReceiver 似乎无法正常工作。我尝试了所有我能找到的解决方案。这是我所拥有的:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" />
<permission android:name="com.my.app.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.my.app.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<activity>....</activity>
<service android:name=".C2DMReceiver"/>
<receiver
android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.my.app"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.my.app"/>
</intent-filter>
</receiver>
在我的 onCreate 方法中,我使用: C2DMessaging.register(this, "mymail@gmail.com");
String id = C2DMessaging.getRegistrationId(this);
并且 id 始终为空。查看 LogCat,我可以看到Permission Denial: received Intent { act=com.google.android.c2dm.intent.REGISTRATION那么,我该怎么办?谢谢)