in my app I have this code to register to the GCM service:
Server.java
protected void registerToGcm() {
GCMRegistrar.checkDevice(mContext);
GCMRegistrar.checkManifest(mContext);
String regId = GCMRegistrar.getRegistrationId(mContext);
if ("".equals(regId)) {
GCMRegistrar.register(mContext, GCMIntentService.SENDER_ID);
} else {
registerToServer(regId);
}
}
GCMIntentService.Java
public static final String SENDER_ID = "1111111111";
@Override
protected void onRegistered(Context context, String regId) {
Log.d(TAG, "Registered to GCM with regId: " + regId);
Server.registerToServer(regId);
}
when I run this code, I see in the server that my device is registering twice with 2 different regIds, and when the server sends a push, the device receives 2 messages.
is this a normal thing? is there a way to ensure only one regId?
What do you need to check when you want to register is