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:
Better than temporarily editing AndroidManifest.xml to remove the permission check, and remembering to restore it later, you can automatically disable the permission check in debug builds.
To do this, set the attribute via a Manifest Merger placeholder:
then set the placeholder in build.gradle:
buildTypes {
debug {
...
manifestPlaceholders = [gcmPermissionRequired: ""] // "" => let the GCM BroadcastReceiver accept Intents from 'adb shell am broadcast'
}
release {
...
manifestPlaceholders = [gcmPermissionRequired: "com.google.android.c2dm.permission.SEND"]
}
}
(Note: Previously I used debug & release string resources. It turns out that the Play store rejects the app if it defines an intent filter permission using a string resource.)