title: GCMRegistrar getRegistrationId return empty ID
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11341305/android-gcm-gcmregistrar-gives-empty-registration-id">Android GCM : GCMRegistrar gives empty registration ID</a>  </p>
  </blockquote>
  
  
  
  <p>I have followed <a href="http://developer.android.com/guide/google/gcm/gs.html#server-app" rel="nofollow noreferrer">Writing the Server-side Application</a> to implement GCM in my application, but</p>
  
  <pre><code>        final String regId = GCMRegistrar.getRegistrationId(this);
  </code></pre>
  
  <p>return empy. All the time.</p>
  
  <p>I put all permissions properly.</p>
  
  <p>There's the code :</p>
  
  <pre><code>    public void registerPush(){
  
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    final String regId = GCMRegistrar.getRegistrationId(this);
    REG_ID = regId;
    if (regId.equals("")) {
     GCMRegistrar.register(this, this.getString(R.string.SENDER_ID));
    } else {
     if (GCMRegistrar.isRegisteredOnServer(this)) {
      // Skips registration.
     } 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 = forceRegister(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>Thanks for the help!</p>
  
  <p><strong>EDIT:</strong> manifest.xml</p>
  
  <p>
  </p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="17" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  
  &lt;permission
      android:name="package.permission.C2D_MESSAGE"
      android:protectionLevel="signature" /&gt;
  &lt;uses-permission android:name="package.permission.C2D_MESSAGE" /&gt;
  
  &lt;application&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="package" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;service android:name="package.GCMIntentService" /&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>