如何使用权限的命令行发送广播 [英] How to send broadcast with permission from command line
问题描述
我有一个应用的广播接收机,它使用我的许可 com.myexample.permission.MY_PERMISSION
。
I have a broadcast receiver in a app which uses my permission com.myexample.permission.MY_PERMISSION
.
我能够用来发送广播
sendBroadcast(意向,com.myexample.permission.MY_PERMISSION)
从活动。
要发送的行动作为广播 com.com.myexample.MY_ACTION
和键 MY_EXTRA
额外数据以下命令可以用于:
To send a broadcast for action as com.com.myexample.MY_ACTION
and extra data with key as MY_EXTRA
below command can be used:
$adb shell am broadcast -a com.com.myexample.MY_ACTION
--ez MY_EXTRA true
但如何许可 com.myexample.permission.MY_PERMISSION
从命令行中使用亚行的shell命令??发送广播的应用
But how to send broadcast with permission com.myexample.permission.MY_PERMISSION
to the app from command line using adb shell commands??
推荐答案
如果我的回答 href=\"http://stackoverflow.com/a/35194227/3928104\">是不是你是什么寻找,尝试下午补助PACKAGE PERMISSION
:
- 添加
发展
级别定义时com.myexample.permission.MY_PERMISSION
在您的应用程序,如安卓的ProtectionLevel =签名|发展
- 将此权限授予壳亚行的shell:结果
下午补助com.android.shell com.myexample.permission.MY_PERMISSION
- add
"development"
level when definecom.myexample.permission.MY_PERMISSION
in your app, likeandroid:protectionLevel="signature|development"
- grant this permission to "shell" in adb shell:
pm grant com.android.shell com.myexample.permission.MY_PERMISSION
这篇关于如何使用权限的命令行发送广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!