GCM :Multiple Application ID in Server side
<p>On server side, i found for one device there multiple registration IDs, which obviously is creating for me lots of issues. like messages received many times.</p>

<p>How could I get red of old registration IDs, or make sure that registration doesn't happen if there a valid registration ID.  </p>

<p>I follow the example tutorial on Android doc when I wrote my app as below:</p>

<pre><code>checkNotNull(SERVER_URL, "SERVER_URL");
        checkNotNull(SENDER_ID, "SENDER_ID");
        // Make sure the device has the proper dependencies.
        GCMRegistrar.checkDevice(this);
        // Make sure the manifest was properly set - comment out this line
        // while developing the app, then uncomment it when it's ready.
        // NOT required any more GCMRegistrar.checkManifest(this);

        /**
         * this code to register reciver moved to message actvity
         */
        //registerReceiver(mHandleMessageReceiver, new IntentFilter(
        //      DISPLAY_MESSAGE_ACTION));


        /* final String */regId = GCMRegistrar.getRegistrationId(this);

        /**
         * save regId in pref to be used by Location update service
         */
        SavePreferences("regId", regId);

        if (regId.equals("")) {
            // Automatically registers application on startup.
            GCMRegistrar.register(this, SENDER_ID);
        } else {
            // Device is already registered on GCM, check server.
            if (GCMRegistrar.isRegisteredOnServer(this)) {
                ;;
                // Skips registration.
                // -- mDisplay.append(getString(R.string.already_registered) +
                // "\n");
            //  System.out.println(getString(R.string.already_registered)
                //      + "\n");

            } else {
                // Try to register again, but not in the UI thread.
                // It's also necessary to cancel the thread onDestroy(),
                // hence the use of AsyncTask instead of a raw thread.
                final Context context = this;
                mRegisterTask = new AsyncTask&lt;Void, Void, Void&gt;() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        boolean registered = ServerUtilities.register(context,
                                regId);
                        // At this point all attempts to register with the app
                        // server failed, so we need to unregister the device
                        // from GCM - the app will try to register again when
                        // it is restarted. Note that GCM will send an
                        // unregistered callback upon completion, but
                        // GCMIntentService.onUnregistered() will ignore it.
                        if (!registered) {
                            GCMRegistrar.unregister(context);
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        mRegisterTask = null;
                    }

                };
                mRegisterTask.execute(null, null, null);
            }
        }
</code></pre>

<p>EDIT: Notice, I could receive messages on the device. </p>
