在这里插入图片描述
报错问题:Permission Denial: broadcast asks to run as user -2 but is calling from user 0;
this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS

解决:
1、权限问题
添加

<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
   tools:ignore="ProtectedPermissions" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"
   tools:ignore="ProtectedPermissions" android:protectionLevel="signature"/>

2、用户权限

String cmd = "am broadcast  --user 0 -a android.intent.action.NAVIBAR_STATUSBAR --ez show false"
Runtime mRuntime = Runtime.getRuntime();
Process mProcess = mRuntime.exec(cmd);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐