How to send broadcast with permission from command line

前端 未结 3 1415
情深已故
情深已故 2021-02-10 05:38

I have a broadcast receiver in a app which uses my permission com.myexample.permission.MY_PERMISSION.

I am able to send the broadcast using

se

相关标签:
3条回答
  • 2021-02-10 05:56

    Use arg --receiver-permission which belongs to subcmd broadcast:

    adb shell am broadcast -a com.com.myexample.MY_ACTION --receiver-permission com.myexample.permission.MY_PERMISSION
    
    0 讨论(0)
  • 2021-02-10 05:58

    Taking a look at this post try removing the permission temporarily when you're doing testing from adb, and then re-adding the permission when you're ready to test it through a real broadcast.

    If that is not acceptable, this post may be of some help.

    0 讨论(0)
  • 2021-02-10 06:13

    If my answer here is not what you are looking for, try pm grant PACKAGE 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
    0 讨论(0)
提交回复
热议问题