ITmob-Ly
发布于 2024-01-16 / 171 阅读
0

Android Exception - 为什么在小米miui系统上监听不到 BOOT_COMPLETED 广播?process is not permitted to auto start

异常信息

在小米miui系统的设备上监听 BOOT_COMPLETED 广播时,收不到 android.intent.action.BOOT_COMPLETED 广播,在 Logcat 中看到如下信息:

2024-01-15 18:28:17.408  1495-3651  BroadcastQueueInjector  system_server  W  Unable to launch app cn.itmob.demo/10253 for broadcast Intent { act=android.intent.action.BOOT_COMPLETED flg=0x89000010 (has extras) }: process is not permitted to  auto start

异常原因

这是因为小米对后台自启动进行了限制,增加了一个后台启动权限,可以打开设置页面中的 “Background autostart/后台启动管理” 页面,打开应用的授权后才能收到 BOOT_COMPLETED 广播。

后台启动管理页面:

设置 → 应用设置 → 授权管理 → 后台启动管理

BackgroundautostartinXiaomidevice.jpeg