Calling a method in the system process without a qualified user
时间: 2023-12-17 18:43:26 浏览: 341
回答: 如果在没有合格用户的情况下调用系统进程中的方法会出现这个异常。可能是因为在Android 4.2之后,引入了多用户支持,有些特殊权限启动服务或者发送广播会失败。为了解决这个问题,可以将之前的启动服务或发送广播的方式改为使用下面的调用方式:public void startActivityAsUser(Intent intent, UserHandle user); public void sendBroadcastAsUser(Intent intent, UserHandle user); public ComponentName startServiceAsUser(Intent service, UserHandle user); public boolean stopServiceAsUser(Intent service, UserHandle user);其中,UserHandle参数可以使用以下常量进行指定:UserHandle.ALL, UserHandle.CURRENT, UserHandle.CURRENT_OR_SELF, UserHandle.OWNER。这样就可以避免在没有合格用户的情况下调用系统进程中的方法而产生异常了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Android代码异常Calling a method in the system process without a qualified user](https://blog.csdn.net/Jason_Lee155/article/details/125843832)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Calling a method in the system process without a qualified user](https://blog.csdn.net/chenfeifei521/article/details/119608982)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文