private void unregister() {
Intent unregIntent = new Intent(
"com.google.android.c2dm.intent.UNREGISTER");
unregIntent.putExtra("app",
PendingIntent.getBroadcast(this, 0, new Intent(), 0));
startService(unregIntent);
}
我调用此函数但返回给我
com.google.android.c2dm.intent.REGISTRATION
而不是com.google.android.c2dm.intent.UNREGISTRATION
?
当我打电话时unregister()
,它运行
if ("com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
final String registrationId = intent
.getStringExtra("registration_id");
String deviceId = Secure.getString(context.getContentResolver(),
Secure.ANDROID_ID);
sendRegistrationIdToServer(deviceId, registrationId);
System.out.println(registrationId.toString());
// createNotification(context, registrationId);
}
这是我的androidmanifest.xml
,是否需要添加注销?
<receiver
android:name=".C2DM_RegistrationReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="oriental.orientalOnePaper" />
</intent-filter>
</receiver>
<receiver
android:name=".C2DM_MessageReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="oriental.orientalOnePaper" />
</intent-filter>
</receiver>