main中的致命异常

问题描述 投票:-1回答:1

我是入门级开发人员,我试图创建一个用于在SIM卡之间进行切换的脚本,并且我输入了adb shell service call之类的命令,现在没有识别出SIM卡,并且手机一直在重启。logcat显示以下崩溃日志(com.android.phone上的致命异常被重复了大约6到7次,但是出于明显的原因,我只是将它们删减了。)

01-03 18:55:52.770  6868  6868 E AndroidRuntime: FATAL EXCEPTION: main
01-03 18:55:52.770  6868  6868 E AndroidRuntime: Process: com.android.phone, PID: 6868
01-03 18:55:52.770  6868  6868 E AndroidRuntime: java.lang.RuntimeException: Number of active slots 1 does not match the expected value 2
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at com.android.internal.telephony.uicc.UiccController.onGetSlotStatusDone(UiccController.java:571)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at com.android.internal.telephony.uicc.UiccController.handleMessage(UiccController.java:405)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Unknown Source:21)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at android.os.Looper.loop(Unknown Source:207)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at android.app.ActivityThread.main(Unknown Source:107)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
01-03 18:55:52.770  6868  6868 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
01-03 18:55:55.842  6255  6255 E AndroidRuntime: FATAL EXCEPTION: main
01-03 18:55:55.842  6255  6255 E AndroidRuntime: Process: pl.zdunex25.updater, PID: 6255
01-03 18:55:55.842  6255  6255 E AndroidRuntime: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3e0fce0 u0 pl.zdunex25.updater/.AlarmService}
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(Unknown Source:335)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Unknown Source:21)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at android.os.Looper.loop(Unknown Source:207)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at android.app.ActivityThread.main(Unknown Source:107)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
01-03 18:55:55.842  6255  6255 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
java android main fatal-error
1个回答
0
投票

前一段时间,我们决定不让用户知道就不能在后台运行服务。

API >= 26中,您需要作为前台启动服务(只要该服务可操作,便会向用户显示即时通知-例如:音乐播放器等。

您将找到更多信息here

您也可以看到此implementation example

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.