title: GCM - registerID is empty immediately after register is complete
body: <p>I finally got the app working to use GCM (Google Cloud Messaging). But I have a problem. The moment right after the registration is complete, I want to get the registrationId. Except the registrationId is empty, unless I restart the app, then it gives back an value.</p>
  
  <p>Basically what I want is to retrieve the registerId right after the registration is complete.</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>checkNotNull(SENDER_ID, "SENDER_ID");
  
  GCMRegistrar.checkDevice(this);
  GCMRegistrar.checkManifest(this);
  
  TextView mDisplay = (TextView) findViewById(R.id.display);
  
  String regId = "";
  
  if (!GCMRegistrar.isRegistered(this))
  {
      mDisplay.setText("registering");
      GCMRegistrar.register(this, SENDER_ID);
  
      regId = GCMRegistrar.getRegistrationId(this);
      String url = "localhost/Google-Cloud-Messaging-Server-Test/registration.php?regId=" + regId;
  
      Log.i(TAG, "registration url: " + url);
      HttpRequest httprequest = new HttpRequest(url);
  }
  else
  {
      regId = GCMRegistrar.getRegistrationId(this);
  
      mDisplay.setText(regId);
      Log.v(TAG, "Already registered");
  
      GCMRegistrar.unregister(this);
  }
  </code></pre>
  
  <p>The problem is that after the code reaches this point:  </p>
  
  <pre><code>regId = GCMRegistrar.getRegistrationId(this);
  String url = "localhost/Google-Cloud-Messaging-Server-Test/registration.php?regId=" + regId;
  </code></pre>
  
  <p>the regId is empty. It should have a value, because the registration succeeds.
  Am I doing something wrong? Is there a possibility that it tries to get the registrationId while it actually is still going through the register process?</p>
  
  <p>Thanks in advance,<br>
  Mark</p>
  
  <p>EDIT: the manifest.xml content</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.codeglue.google.cloud.messaging.test"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="10"
      android:targetSdkVersion="15" /&gt;
  
  &lt;permission
      android:name="com.codeglue.google.cloud.messaging.test.permission.C2D_MESSAGE"
      android:protectionLevel="signature" /&gt;
  
  &lt;uses-permission android:name="com.codeglue.google.cloud.messaging.test.permission.C2D_MESSAGE" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" &gt;
  
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name" &gt;
  
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;receiver
          android:name="com.google.android.gcm.GCMBroadcastReceiver"
          android:permission="com.google.android.c2dm.permission.SEND" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
              &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
  
              &lt;category android:name="com.codeglue.google.cloud.messaging.test" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;service android:name=".GCMIntentService" /&gt;
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>