今天遇到一个小问题,记录下。
在Android 8.0系统上,我启动一个Service,创建通知渠道及Notification,并调用其startForeground方法时,出现了system ui has stopped的异常,现象及代码如下:


问题解决:
该问题是因创建Notification时未设置icon引起的,且icon资源不能在mipmap目录下,因此将创建Notification的代码修改如,即可正常显示通知:

今天遇到一个小问题,记录下。
在Android 8.0系统上,我启动一个Service,创建通知渠道及Notification,并调用其startForeground方法时,出现了system ui has stopped的异常,现象及代码如下:
问题解决:
该问题是因创建Notification时未设置icon引起的,且icon资源不能在mipmap目录下,因此将创建Notification的代码修改如,即可正常显示通知:
本文标题:Android 8.0 Service创建通知报错 system
本文链接:https://www.haomeiwen.com/subject/lxjlbqtx.html
网友评论