【问题标题】:Unable to send android.intent.action.BOOT_COMPLETED from adb shell无法从 adb shell 发送 android.intent.action.BOOT_COMPLETED
【发布时间】:2017-01-29 03:09:09
【问题描述】:

我正在构建一个应用程序,它需要在设备启动时自动启动服务。

我想用 adb 测试这个功能。当我从 adb 发出以下命令时

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

我收到以下错误。

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)

根据这个答案stackoverflow.com/a/10105047/106248其他人没有遇到这个问题。

我正在测试的操作系统版本是 Android 7.0。我在真实设备和模拟器上都面临同样的问题。

请帮我解决问题。

谢谢

【问题讨论】:

标签: android adb android-broadcastreceiver


【解决方案1】:

以 root 模式重新启动 ADB 为我解决了这个问题:

adb root

【讨论】:

  • 您好,知道您不久前回答了这个问题,我可以知道您使用的确切命令吗?你是先adb root然后是广播commadn还是adb root shell am...
  • 它是adb root(假设您有一个设备),它应该返回消息“restarting adbd as root”。然后单独调用adb shell 以进入shell(以root 身份)。据我了解,这只能在模拟器上完成。
  • 我从一个真实的设备上得到adbd cannot run as root in production builds。那么它只适用于模拟器吗?
猜你喜欢
  • 2012-07-05
  • 1970-01-01
  • 2013-04-02
  • 1970-01-01
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多