[英]Unable to send android.intent.action.BOOT_COMPLETED from adb shell
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. 我想使用adb测试此功能。 When I issue the following command from adb
当我从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. 根据这个答案stackoverflow.com/a/10105047/106248,其他人没有遇到这个问题。
The OS version I am testing on is Android 7.0. 我正在测试的操作系统版本是Android 7.0。 I am facing the same problem on both real device and emulator.
我在真实设备和仿真器上都面临相同的问题。
Please help me solve the problem. 请帮我解决问题。
Thank you 谢谢
在root模式下重新启动ADB为我解决了这个问题:
adb root
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.