最近用戶反饋華爲手機用戶使用後奔潰問題,發現主要是後臺啓動服務的問題,錯誤信息如下:
java.lang.RuntimeException: Unable to resume activity {com.example.kingnew/com.example.king.MainActivity}: java.lang.IllegalStateException: Not allowed to start service Intent
如上錯誤的詳情參考: https://blog.csdn.net/kongbaidepao/article/details/80259150
另外列出幾點自己修改時遇到的問題:
-
配置文件中增加權限
否則報錯:java.lang.SecurityException: Permission Denial: requires android.permission.FOREGROUND_SERVICE -
android.app.RemoteServiceException: Bad notification for startForeground:
java.lang.RuntimeException: invalid channel for service notification:
Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE) -
Android通知欄微技巧,8.0系統中通知欄的適配
https://blog.csdn.net/guolin_blog/article/details/79854070