使用adb shell am start com.njzx.care/com.njzx.care.activity.MainActivity启动某应用,报错权限问题。

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.L
AUNCHER] cmp=com.njzx.care/.activity.MainActivity }
Security exception: Permission Denial: starting Intent { act=android.intent.acti
on.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.njzx.care/
.activity.MainActivity } from null (pid=16408, uid=2000) not exported from uid 1
1148

java.lang.SecurityException: Permission Denial: starting Intent { act=android.in
tent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.n
jzx.care/.activity.MainActivity } from null (pid=16408, uid=2000) not exported f
rom uid 11148
at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPe
rmission(ActivityStackSupervisor.java:1877)
at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.j
ava:607)
at com.android.server.am.ActivityStarter.startActivityLocked(ActivitySta
rter.java:366)
at com.android.server.am.HwActivityStarter.startActivityLocked(HwActivit
yStarter.java:227)
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivitySt
arter.java:1155)
at com.android.server.am.HwActivityStarter.startActivityMayWait(HwActivi
tyStarter.java:372)
at com.android.server.am.ActivityManagerService.startActivityAsUser(Acti
vityManagerService.java:5036)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(Ac
tivityManagerShellCommand.java:410)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityM
anagerShellCommand.java:141)
at android.os.ShellCommand.exec(ShellCommand.java:96)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityM
anagerService.java:16140)
at android.os.Binder.shellCommand(Binder.java:574)
at android.os.Binder.onTransact(Binder.java:474)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:42
64)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManag
erService.java:3285)
at com.android.server.am.HwActivityManagerService.onTransact(HwActivityM
anagerService.java:837)
at android.os.Binder.execTransact(Binder.java:675)

网上解决方案说把androidmanifest.xml中添加:android:exported="true"
然而并没有什么用。


↙↙↙阅读原文可查看相关链接,并与作者交流