I'm trying to simulate as if the device is receiving a GCM push message by using adb and the command line. I've tried this command to broadcast a GCM intent:
adb shell am broadcast -c com.myapp -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData"
This triggers a "Permission denial" log line though:
09-19 12:23:34.820 725-787/? W/BroadcastQueue﹕ Permission Denial: broadcasting Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.myapp] flg=0x10 (has extras) } from null (pid=21244, uid=2000) requires com.google.android.c2dm.permission.SEND due to receiver com.myapp/com.google.android.gcm.GCMBroadcastReceiver
Relevant parts of my manifest:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <application> <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.myapp" /> </intent-filter> </receiver> </application>
Any ideas?
Edit / clarification: Push / GCM receive works in production. I'm looking for an easier way to test changes.
Open a command window in the folder by holding shift and right-clicking in an empty spot in the folder and selecting "Open command prompt/PowerShell here" in the menu. Then you can start using ADB — connect your phone and try . ADB devices to see if it's working. A list with attached devices should show up.
To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options. To use adb with a device connected over Wi-Fi, see Connect to a device over Wi-Fi. On Android 4.2 and higher, the Developer options screen is hidden by default.
If you're already on Ice Cream Sandwich, go to Settings > Developer options and tick “Android debugging” or “USB debugging.” A result like that (where the X's represent your device's actual serial number) confirms that your ADB is set up and working.
You need to remove the permission property in your receiver's definition like this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <application> <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="com.myapp" /> </intent-filter> </receiver> </application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With