I am building an app, which needs to start a service automatically when the device boots up.
I want to test this functionality with adb. When I issue the following command from adb
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
I get the following error.
Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED }
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.BOOT_COMPLETED from pid=3566, uid=2000
at android.os.Parcel.readException(Parcel.java:1683)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3507)
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)
According to this answer stackoverflow.com/a/10105047/106248 others didn't face this problem.
The OS version I am testing on is Android 7.0. I am facing the same problem on both real device and emulator.
Please help me solve the problem.
Thank you