简体   繁体   中英

Mail Account For C2DM Registration

I am using C2DM for "Push Notification" on Android. Every thing is okay.

My question is; can I get "if device has more than synchronized gmail accounts, which one is used for C2DM"?

Refer this link for C2DM and sample at this LINK . Now you device think where it is related to device.

In the below code the email id use is not device specific. C2DM uses email id just for interaction between server and C2DM not depending on device.

// Call when your application start

public void StartRegistrationNotification()
    {

        Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
        registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
        registrationIntent.putExtra("sender", "....@gmail.com");
        this.startService(registrationIntent);  

}
// change in Manifest File

<receiver android:name="com.ReceiverC2DM"
        android:permission="com.google.android.c2dm.permission.SEND">
        <!-- Receive the actual message -->
        <intent-filter>

            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="yourpackagename" />
        </intent-filter>
        <!-- Receive the registration id -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="yourpackagename" />
        </intent-filter>
    </receiver>
    <permission android:name="yourpackagename.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="yourpackagename.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM