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
sendBroadcast(intent, "com.myexample.permission.MY_PERMISSION")
from activities.
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
But how to send broadcast with permission com.myexample.permission.MY_PERMISSION
to the app from command line using adb shell commands??
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
If my answer here is not what you are looking for, try pm grant PACKAGE PERMISSION
:
"development"
level when define
com.myexample.permission.MY_PERMISSION
in your app, like android:protectionLevel="signature|development"
pm grant com.android.shell com.myexample.permission.MY_PERMISSION
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With