To send or get messages in Android, your application firstly needs to get an enrolment/registration ID. The enrolment/registration ID which recognizes the gadget and application, furthermore figures out which third gathering application servers are permitted to send messages to this application case.
To get an enrolment / registration ID, you must supply one or more sender IDs.
This method will fetch registration ID from google.
String regId ="",msg ="";
public void getRegisterationID() {
new AsyncTask() {
@Override
protected Object doInBackground(Object... params) {
// TODO Auto-generated method stub
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(Login.this);
}
regId = gcm.register(CommonUtilities.SENDER_ID);
Log.d("in async task", regId);
// try
msg = "Device registered, registration ID=" + regId;
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
}
return msg;
}
}.execute(null, null, null);
}
To get an enrolment / registration ID, you must supply one or more sender IDs.
This method will fetch registration ID from google.
String regId ="",msg ="";
public void getRegisterationID() {
new AsyncTask() {
@Override
protected Object doInBackground(Object... params) {
// TODO Auto-generated method stub
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(Login.this);
}
regId = gcm.register(CommonUtilities.SENDER_ID);
Log.d("in async task", regId);
// try
msg = "Device registered, registration ID=" + regId;
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
}
return msg;
}
}.execute(null, null, null);
}
great...
ReplyDeletethanx
Delete