I have tried some forum pages and searched through stackoverflow for the same thing, but I did not find the solution.
I have used the below code to generate registration ID for GCM notification. But I get an empty string as a registration ID:
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);if (GCMRegistrar.isRegistered(this)) {
Log.d(“info”, GCMRegistrar.getRegistrationId(this));
}regId = GCMRegistrar.getRegistrationId(this); Log.v("log", " register id oslo : " + regId); if (regId.equals("")) { // replace this with the project ID GCMRegistrar.register(this, "718437041388"); Log.d("info", GCMRegistrar.getRegistrationId(this)); } else { Log.d("info", "already registered as" + regId); }
Please help me with this, tell me if I got anything wrong.
Thank you in advance,
Nirav.
You should not get the registrationId just after
GCMRegistrar.register(this, "718437041388");In fact, do you have a correct
GCMIntentService.javawhich receive the regId?If yes, you can get the regId from the
onRegisteredinsideGCMIntentService.java