title: C2DM Broadcast Receiver
body: <p>I had a working C2DM application. 
  I reused the same package name when creating a new C2DM application. </p>
  
  <p>It works except now the BroadcastReceiver doesn't get called when the application is not running. That is to say it all works if I run the application and send it C2DM messages. But after a force quit the BroadcastReceiver is no longer called.</p>
  
  <p>I have looked at a lot of examples and compared everything in my old manifest to the new one. Paying extra attention to package names used in categories, Intent Services, etc..</p>
  
  <p>Question: Is there a common C2DM coding/config mistake that results in the BroadcastReceiver not being called after an app is force quit?</p>
  
  <p>I do get this log cat when I send a C2DM message after force quit of my application:</p>
  
  <p>01-11 00:54:43.580: WARN/GTalkService(286): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.aawwpcd.pcd3] (has extras) }</p>
  
  <p>I get one of those for each C2DM message I send to the device after force quitting the application. </p>
  
  <p>It looks like the intent is coming in but not being passed to my BroadcastReceiver.</p>
  
  <p>Edit:</p>
  
  <p>Here are the relavant bits from the Manifest and BroadcastReceiver:</p>
  
  <p><strong>BroadcastReciever</strong></p>
  
  <pre><code>package com.aawwpcd.pcd3.c2dm;
  
  import ...
  
  public class C2DMBroadcastReceiver extends BroadcastReceiver {
  
      @Override
      public IBinder peekService(Context myContext, Intent service) {
          return super.peekService(myContext, service);
      }
  
      public C2DMBroadcastReceiver() {
          super();
      }
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
      ...
  
      }
  
  }
  </code></pre>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.aawwpcd.pcd3"
        android:versionCode="250"
        android:versionName="ICSPCD3"&gt;
  
  &lt;uses-sdk android:minSdkVersion="13"
            android:targetSdkVersion="14"/&gt;
  
  &lt;permission android:name="com.aawwpcd.pcd3.permission.C2D_MESSAGE" android:protectionLevel="signature"/&gt;
  &lt;uses-permission android:name="com.aawwpcd.pcd3.permission.C2D_MESSAGE"/&gt;
  &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
  
  &lt;application android:name=".PCD3Application"
               android:label="@string/app_name"
               android:icon="@drawable/pcdlauncher"
               android:theme="@android:style/Theme.Holo"&gt;
  
      &lt;activity android:name=".honeycombpcd3.FullScheduleActivity"
                android:label="@string/app_namefull"
              &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;!-- Only C2DM servers can send messages for the app. If permission is not
      set - any other app can generate it --&gt;
      &lt;receiver android:name=".c2dm.C2DMBroadcastReceiver"
                android:permission="com.google.android.c2dm.permission.SEND"&gt;
  
          &lt;!-- Receive the actual message --&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.android.c2dm.intent.RECEIVE"/&gt;
              &lt;category android:name="com.aawwpcd.pcd3"/&gt;
          &lt;/intent-filter&gt;
  
          &lt;!-- Receive the registration id --&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION"/&gt;
              &lt;category android:name="com.aawwpcd.pcd3"/&gt;
          &lt;/intent-filter&gt;
  
      &lt;/receiver&gt;
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Edit: Could this be something new in 3.x ? As stated above my problems started with this new application - written for 3.x. What I want is for the C2DM to call the BroadcastReceiver even when the application is not running. I am not seeing that. Could it be a 3.x change? It worked this way before on 2.3.x phones and I can't find anything I am doing different. It will be a hassle to write the test code to prove this but that's next I guess.</p>
  
  <p>Edit:
  Seems related to Force Quit. I don't have any problem when I re-install the .apk and then send the device a c2dm message; the Broadcast receiver picks it up. In this case the application was not already running when the C2DM came in yet everything worked as expected. The only problem I am having is after I force quit an application. C2DM messages after that are not picked up by the BroadcastReceiver. </p>