title: GCM not Working
body: <p>I am learning <strong>GCM(Google cloud Messaging)</strong><br />
  I Completed Following steps</p>
  
  <p><strong>1</strong> - Activated and Obtained a Key for browser apps</p>
  
  <p><strong>2</strong> - added  following in manifest</p>
  
  <p><em>Uses permission</em> :  com.google.android.c2dm.permission.RECEIVE</p>
  
  <p>Created permission to prevent other Android applications from registering and receiving the Android application's messages</p>
  
  <p>Created a receiver for com.google.android.c2dm.intent.RECEIVE, with the category set as applicationPackage. The receiver should require the com.google.android.c2dm.SEND permission</p>
  
  <p><strong>3</strong> – in receiver</p>
  
  <pre><code>@Override
  
  public void onReceive(Context context, Intent intent) {
  
      ComponentName comp = new ComponentName(context.getPackageName(),
          GcmMessageHandler.class.getName());
  
      startWakefulService(context, (intent.setComponent(comp)));
  
      setResultCode(Activity.RESULT_OK);
  
  }
  </code></pre>
  
  <p><strong>GcmMessageHandler</strong> it’s a Intend Service to show a notification on receive gcm message.following is onHandleIntent Method in <strong>GcmMessageHandler</strong>.</p>
  
  <pre><code>@Override
  
  protected void onHandleIntent(Intent intent) {
  
      handler.post(new Runnable() {
  
  
          @Override
  
          public void run() {
  
              NotificationManager manager = (NotificationManager) getApplicationContext()
                      .getSystemService(Context.NOTIFICATION_SERVICE);
  
              NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                      getApplicationContext());
  
              mBuilder.setSmallIcon(R.drawable.ic_launcher);
  
              mBuilder.setContentTitle("GCM Received");
  
              mBuilder.setContentText("GCM Message");
  
              manager.notify(1, mBuilder.build());
  
  
          }
  
      });
  
  
      Log.i("app", "Received ");
  
      GcmBroadcastReceiver.completeWakefulIntent(intent);
  
  }
  </code></pre>
  
  <p><strong>4</strong> - MainActivity-to register and get clint ID, from log cat I copyed that id.</p>
  
  <p><strong>5</strong> - from browser I make post request to <a href="https://android.googleapis.com/gcm/send" rel="nofollow">https://android.googleapis.com/gcm/send</a> with authorization,content-type,and registration_ids.</p>
  
  <p>Its gets success message.<br />
  But my device not showing notification.</p>