gpt4 book ai didi

android - 是否可以从 adb shell/am 命令行模拟 GCM 接收?我收到一个错误

转载 作者:IT老高 更新时间:2023-10-28 22:17:19 26 4
gpt4 key购买 nike

我正在尝试使用 adb 和命令行来模拟设备正在接收 GCM 推送消息。我试过这个命令来广播 GCM Intent :

adb shell am broadcast -c com.myapp -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData"

这会触发“权限拒绝”日志行:

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

我的 list 的相关部分:

<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接收生产中的作品。我正在寻找一种更简单的方法来测试更改。

最佳答案

您需要删除接收者定义中的 permission 属性,如下所示:

<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>

关于android - 是否可以从 adb shell/am 命令行模拟 GCM 接收?我收到一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25931902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com