I am trying to use GCM and everything is working fine except for the GCMRegistrar.getRegistrationId call on difference devices. I’ve run this code on an emulator and 2 different phones and GCMRegistrar.getRegistrationId always returns the same string. I expected it to differ on each device but it does not. Am I doing something wrong? Here’s the code I’m using (taken from the docs).
GCMRegistrar.checkDevice(context);
final String regId = GCMRegistrar.getRegistrationId(context);
if (regId.equals("")) {
GCMRegistrar.register(activity, "123456789012"); //sender id/api project id
} else {
LogUtil.info("Already registered");
}
When I first ran this on the emulator GCMRegistrar.getRegistrationId returned “” but on subsequent calls it returns the big id. That makes sense. The strange thing was that when running the same code on the 2 phones, they both returned that same id (the one the emulator returned), having never run this app before.
This actually turned out to be a mistake on my part on how I was checking the id’s. XGouchet, thanks for your response though.