我需要经常重启我的应用程序来测试某些组件的行为。所以我想使用cmd
from 终端,以免浪费时间手动关闭/打开。我找到了这段代码,但是当我放在终端上时,它返回一个权限错误。
CMD 从终端重新启动:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
终端响应:
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.BOOT_COMPLETED from pid=13940, uid=2000
at android.os.Parcel.readException(Parcel.java:1665)
at android.os.Parcel.readException(Parcel.java:1618)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3533)
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)