0
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.REGISTRATIONcom.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>
4

0 に答える 0