app is in background uid UidRecord错误

04-28 08:42:06.576  5425  5425 D AndroidRuntime: Shutting down VM
04-28 08:42:06.578  5425  5425 E AndroidRuntime: FATAL EXCEPTION: main
04-28 08:42:06.578  5425  5425 E AndroidRuntime: Process: jp.co.elmo.elmonote, PID: 5425
04-28 08:42:06.578  5425  5425 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver crc6421942cef9f1dae2f.BootReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=jp.co.elmo.elmonote/crc6414dfc74a030b5a5a.MyAccessibilityService }: app is in background uid UidRecord{f846716 u0a41 RCVR idle change:uncached procs:1 seq(0,0,0)}
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3388)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ActivityThread.access$1200(ActivityThread.java:199)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6669)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=jp.co.elmo.elmonote/crc6414dfc74a030b5a5a.MyAccessibilityService }: app is in background uid UidRecord{f846716 u0a41 RCVR idle change:uncached procs:1 seq(0,0,0)}
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ContextImpl.startService(ContextImpl.java:1532)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.content.ContextWrapper.startService(ContextWrapper.java:664)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.content.ContextWrapper.startService(ContextWrapper.java:664)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at crc6421942cef9f1dae2f.BootReceiver.n_onReceive(Native Method)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at crc6421942cef9f1dae2f.BootReceiver.onReceive(Unknown Source:0)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3379)
04-28 08:42:06.578  5425  5425 E AndroidRuntime: 	... 8 more

Android 8.0 不再允许后台进程直接通过startService方式去启动服务,改为startForegroundService方式启动

参考博客:
https://*.com/questions/64534317/android-11-java-lang-illegalstateexception-not-allowed-to-start-service-intent

上一篇:CopyOnWriteArrayList源码分析


下一篇:Sword 内存屏障-Store Buffer