简体   繁体   中英

In Android C2DM what is Role (sender) account email?

I have searched through net about C2DM and the process of registration of android device to the C2DM is very confusing. In the code below :-

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

What is "app", "sender" and "myapp@example.com"? I tried to signup for the Android C2DM but I couldn't understand what is the Role account email. Any advice is appreciated.

In the code you have shown, the only thing you need to replace is myapp@example.com .

First you need to create a Google GMail account, eg, yourappname@gmail.com

Then you need to go to the Sign Up for Android Cloud to Device Messaging page. Fill in all of the details on the sign up page and provide your GMail account as the 'Role (sender)'. Then in your code, replace myapp@example.com with the GMail address you've created.

EDIT: In response to your comment/question.

rI is an Intent and you are putting 'extra' data into that Intent which is passed to the Google C2DM registration service.

When you put data into an Intent , it has to have a key name so the receiver of the Intent is able to extract it using getStringExtra(keyName) (for example). The keys 'app' and 'sender' are reserved for C2DM registration and MUST be used as they are in that code otherwise the C2DM registration process will fail.

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