I have an app (com.example.myapp
) installed that received C2DM
Intent
s. I would like to piggyback onto this to perform my own processing in response to these Intent
s in a separate app (com.example.myapp2
). According to the this answer, the C2DM
client system looks for:
broadcast receivers for Intent:
com.google.android.c2dm.intent.REGISTRATION
That have the permission:
.permission.C2D_MESSAGE
In the original app, the following permission is defined and used, as specified in the C2DM Documentation
<!-- Only this application can receive the messages and registration result -->
<permission android:name="com.example.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
This is com.example.myapp2
's manifest, in which I use that permission also:
<manifest package="com.example.myapp2" ...>
<!-- Only this application can receive the messages and registration result -->
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Send the registration id to the server -->
<uses-permission android:name="android.permission.INTERNET" />
<application...>
<!-- Only C2DM servers can send messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name=".C2DMReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.myapp" />
<category android:name="com.example.myapp2" />
</intent-filter>
</receiver>
...
</application>
...
</manifest>
My C2DMReceiver
is com.example.myapp2.C2DMReceiver
. Notice that I'm not listening for com.google.android.c2dm.intent.REGISTRATION
Intent
s since I don't care about registering. I only care about receiving the Intent
s that com.example.myapp
is already receiving. In my IntentFilter
for com.google.android.c2dm.intent.RECEIVE
Intent
s, I filter for both com.example.myapp
and com.example.myapp2
category
s since C2DM
isn't specific about exactly what a C2DM
Intent
looks like. Any help there would be appreciated.
I've verified that com.example.myapp2
has the com.example.myapp.permission.C2D_MESSAGE
permission. If I run with a debug key, I don't have it, but if I run with the release key, I have it. Obviously, I'm running the version on my device with the release key.
When com.example.myapp
receives a C2DM
Intent
com.example.myapp2
doesn't receive it. Any ideas for how to debug or how to get this to work? Is it even possible?