title: GCM onMessage not called
body: <p>I've scoured the internet and couldn't get my GCM server/client working.</p>
  
  <p>I suspect that its a problem on the client side because I get a success response from the server side.</p>
  
  <p>Anyway I'm clipping both client code and server code.</p>
  
  <p>BTW I can register my device ID.</p>
  
  <p>Server side </p>
  
  <pre><code>        Sender sender = new Sender(apiKey);
  
          Message message = new Message.Builder()
          .delayWhileIdle(true)
          .addData("AUB",text)
          .build(); 
  
          Result result = null;
          try {
              result = sender.send(message, deviceID, 5);
              return "sent " + "Message ID:" + result.getMessageId() + message.getData();
          } catch (IOException e) {
              e.printStackTrace();
              return "error: " + result.getErrorCodeName();
          }
  </code></pre>
  
  <p>Client Side</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.mainactivity);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
          GCMRegistrar.checkDevice(this);
          GCMRegistrar.checkManifest(this);
  
          registerReceiver(mHandleMessageReceiver, new IntentFilter(
                  Constants.DISPLAY_MESSAGE_ACTION));
          String regId = GCMRegistrar.getRegistrationId(this);
          if (regId.equals("")) {
              GCMRegistrar.register(this, Constants.SENDER_ID);
              Log.v(TAG, "Registered");
          } else {
              Log.v(TAG, "Already registered");
              Log.v(TAG, GCMRegistrar.getRegistrationId(this));
          }
  
      }
  
  private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              String newMessage = intent.getExtras().getString(
                      Constants.EXTRA_MESSAGE);
              Log.v(TAG, newMessage);
          }
      };
  </code></pre>
  
  <p>GCMIntentService</p>
  
  <pre><code>public class GCMIntentService extends GCMBaseIntentService {
  
      public GCMIntentService() {
          super(Constants.SENDER_ID);
      }
  
      @Override
      protected void onError(Context arg0, String arg1) {
  
      }
  
      @Override
      protected void onRegistered(Context context, String registrationId) {
          Log.v(TAG, "Device registered: regId = " + registrationId);
  
      }
  
      @Override
      protected void onUnregistered(Context arg0, String arg1) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      protected void onMessage(Context context, Intent intent) {
          Log.i(TAG, "Received message");
          String message = "AUB";
          Constants.displayMessage(context, message);
          // notifies user
          generateNotification(context, message);
      }
  
      private static void generateNotification(Context context, String message) {
          int icon = R.drawable.ic_launcher;
          long when = System.currentTimeMillis();
          NotificationManager notificationManager = (NotificationManager)
                  context.getSystemService(Context.NOTIFICATION_SERVICE);
          Notification notification = new Notification(icon, message, when);
          String title = context.getString(R.string.app_name);
          Intent notificationIntent = new Intent(context, MainActivity_.class);
          // set intent so it does not start a new activity
          notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                  Intent.FLAG_ACTIVITY_SINGLE_TOP);
          PendingIntent intent =
                  PendingIntent.getActivity(context, 0, notificationIntent, 0);
          notification.setLatestEventInfo(context, title, message, intent);
          notification.flags |= Notification.FLAG_AUTO_CANCEL;
          notificationManager.notify(0, notification);
      }
  
  }
  </code></pre>
  
  <p>Manifest</p>
  
  <pre><code>&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=".GCMIntentService" android:enabled="true"/&gt;
  
  &lt;permission
          android:name="PACKAGE.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
      &lt;!-- Permissions for GCM --&gt;
      &lt;!-- App receives GCM messages. --&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;!-- GCM requires a Google account. --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;!-- Keeps the processor from sleeping when a message is received. --&gt;
      &lt;!--  --&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="PACKAGE.permission.C2D_MESSAGE" /&gt;
      &lt;uses-permission android:name="PACKAGE.permission.MAPS_RECEIVE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>I've resolved the issue. Apparently our network was blocking the port 5228.</p>