Reputation: 131
I am trying to receive push notifications on my device, using the below adb shell command:
adb shell am broadcast -c com.xxxx.android -a com.google.android.c2dm.intent.RECEIVE -e data "Data"
But I am not receiving any push messages or errors.
This is the output I get:
Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.myapp] (has extras) } Broadcast completed: result=0
Upvotes: 13
Views: 28266
Reputation: 875
Use should use key -n instead -c.
Key -c is category key.
[-c <CATEGORY> [-c <CATEGORY>] ...]
Use this command, just change your package name:
adb shell am broadcast -n com.myapp -a com.google.android.c2dm.intent.RECEIVE -e key "data"
Upvotes: 1
Reputation: 15116
Here is the basic use of adb broadcast command:
adb shell am broadcast
-a <INTENT_NAME>
-n <PACKAGE_NAME>/<RECEIVER_NAME>
[--ei <EXTRA_KEY> <EXTRA_INT_VALUE>]
[--es <EXTRA_KEY> <EXTRA_STRING_VALUE>]
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>]
[--el <EXTRA_KEY> <EXTRA_LONG_VALUE>]
[--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>]
[--eu <EXTRA_KEY> <EXTRA_URI_VALUE>]
[--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
[--e*a <EXTRA_KEY> <EXTRA_*_VALUE>[,<EXTRA_*_VALUE...]]
And you can find the RECEIVER_NAME in your AndroidManifest.xml:
<receiver
android:name="foo.bar.SomeBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="xyz.abc" />
</intent-filter>
</receiver>
Example command:
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -n <YOUR_PACKAGE_NAME>/<YOUR_RECEIVER_NAME> --es "<EXTRA_KEY>" "<EXTRA_VALUE>"
Upvotes: 13