I would like to test my boot receiver (android.intent.action.BOOT_COMPLETED) on a real device running Android 7.1.1 I tried to use this command from the command prompt:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p [package_name]
but it returns ad exception:
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.BOOT_COMPLETED from pid=11114, uid=2000
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3537)
at com.android.commands.am.Am.sendBroadcast(Am.java:772)
at com.android.commands.am.Am.onRun(Am.java:404)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.am.Am.main(Am.java:121)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)
I've already tried the solution offered by Android - Trying to test a service on boot (java.lang.SecurityException: Permission Denial) but it doesn't work for me.
How can I solve this?
Thanks in advance! :)