title: GCMBaseIntentService onMessage method never called
body: <p>i'm mostly new to android technologies. I had a project where GCM was working. Now I merged that project with other and GCM just stopped working...</p>
  
  <p>My service is calling onRegistered method properly, but when I send a message to the phone nothing is happening.</p>
  
  <p>Any ideas??
  Here is GCMBaseIntentService.java</p>
  
  <pre><code>package com.example.truque;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.Date;
  
  import android.app.Notification;
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.Context;
  import android.content.Intent;
  import android.util.Log;
  
  import com.google.android.gcm.GCMBaseIntentService;
  
  
  public class GCMIntentService extends GCMBaseIntentService {
  
      private static final String PROJECT_ID = "733836832755";
  
      private static final String TAG = "ACAAAAAAAAAAAA!!!!!!";
  
      public GCMIntentService()
      {
          super(PROJECT_ID);
          Log.d(TAG, "GCMIntentService init");
      }
  
  
      @Override
      protected void onError(Context ctx, String sError) {
          // TODO Auto-generated method stub
          Log.d(TAG, "Error: " + sError);
  
      }
  
      @Override
      protected void onMessage(Context ctx, Intent intent) {
  
          Log.d(TAG, "Message Received");
  
          String message = intent.getStringExtra("message");
  
          sendGCMIntent(ctx, message);
  
      }
  
  
      private void sendGCMIntent(Context ctx, String message) {
  
          Intent broadcastIntent = new Intent();
          broadcastIntent.setAction("GCM_RECEIVED_ACTION");
  
          broadcastIntent.putExtra("gcm", message);
  
          ctx.sendBroadcast(broadcastIntent);
          /////////////////////////////////////////////////////////////////
          String ns = Context.NOTIFICATION_SERVICE;
          NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(ns);
  
          int icon = R.drawable.ic_launcher;        
          CharSequence tickerText = "Leeme"; // ticker-text
          long when = System.currentTimeMillis();         
          Context con = ctx.getApplicationContext();     
          CharSequence contentTitle = "Mensaje recibido";  
          CharSequence contentText = message;      
          Intent notificationIntent = new Intent(ctx, MainActivity.class);
          PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
          Notification notification = new Notification(icon, tickerText, when);
          notification.setLatestEventInfo(con, contentTitle, contentText, contentIntent);
          notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
          // and this
          int HELLO_ID = 1;
          mNotificationManager.notify(HELLO_ID, notification);
  
          File f = new File("messages.txt");
          if(!f.exists()){
              try {
                  FileOutputStream fos = ctx.openFileOutput("messages.txt", Context.MODE_APPEND);
  
                  String c=getCanal(message);
                  String n=getNick(message);
                  String m=getMensaje(message);
                  fos.write(("["+(new Date()).toString()+"]["+c+"]["+n+"] "+m).getBytes());
                  fos.write(System.getProperty("line.separator").getBytes());
                  fos.close();
  
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
  
          }
  
          ///////////////////////////////////////////////////////////////////
      }
  
      String getCanal(String m){
          return "Canal N";
      }
      String getNick(String m){
          return "Nick N";
      }
      String getMensaje(String m){
          return m;
      }
  
      @Override
      protected void onRegistered(Context ctx, String regId) {
          // TODO Auto-generated method stub
          // send regId to your server
          Log.d(TAG, regId);
  
      }
  
      @Override
      protected void onUnregistered(Context ctx, String regId) {
          // TODO Auto-generated method stub
          // send notification to your server to remove that regId
          Log.d("Unregistered ACAAAAA!!", regId);
      }
  
  }
  </code></pre>
  
  <p>and AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.truque"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="18" /&gt;
  
      &lt;permission
          android:name="com.example.truque.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-permission android:name="com.example.truque.permission.C2D_MESSAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;!-- receives GCM messages --&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;!-- GCM connects to Google services --&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;!-- GCM requires a Google account --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission android:name="android.permission.USE_CREDENTIALS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_OWNER_DATA" /&gt;
  
      &lt;!-- wake the processor if a GCM message is received --&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.truque.MainActivity"
              android:label="@string/app_name" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.truque.LoginActivity"
              android:label="@string/title_activity_login"
              android:windowSoftInputMode="adjustResize|stateVisible" &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;activity
              android:name="com.example.truque.AltaUsuario"
              android:label="@string/title_activity_alta_usuario" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.truque.Notis"
              android:label="@string/title_activity_notis"
              android:theme="@android:style/Theme.Dialog" &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.example.truque" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;service 
              android:name=".GCMIntentService" &gt;
          &lt;/service&gt;
          &lt;receiver
              android:name="com.example.truque.PushReceiver"
              android:enabled="true"
              android:exported="true" &gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>