是否有可能模拟GCM从亚行的shell / AM命令行收到?我发现了一个错误 [英] Is it possible to simulate a GCM receive from the adb shell / am command line? I'm getting an error
本文介绍了是否有可能模拟GCM从亚行的shell / AM命令行收到?我发现了一个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图模拟的设备是否使用亚行和命令行接收GCM推送消息。我试过这个命令广播GCM意图:
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>
任何想法?
编辑/澄清:一键/ GCM接收生产工作。我正在寻找一个更简单的方法来测试更改。
Edit / clarification: Push / GCM receive works in production. I'm looking for an easier way to test changes.
推荐答案
您需要删除的许可属性接收机的像这样的定义:
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>
这篇关于是否有可能模拟GCM从亚行的shell / AM命令行收到?我发现了一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文