如何使用权限的命令行发送广播 [英] How to send broadcast with permission from command line

查看:1195
本文介绍了如何使用权限的命令行发送广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用的广播接收机,它使用我的许可 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


  1. 添加发展级别定义时
    com.myexample.permission.MY_PERMISSION 在您的应用程序,如安卓的ProtectionLevel =签名|发展

  2. 将此权限授予壳亚行的shell:结果
    下午补助com.android.shell com.myexample.permission.MY_PERMISSION

  1. add "development" level when define com.myexample.permission.MY_PERMISSION in your app, like android:protectionLevel="signature|development"
  2. grant this permission to "shell" in adb shell:
    pm grant com.android.shell com.myexample.permission.MY_PERMISSION

这篇关于如何使用权限的命令行发送广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆