为了账号安全,请及时绑定邮箱和手机立即绑定

android第一行代码(第二版)第十章serviceBestPractice,日志显示Handler和Looper中有错误

android第一行代码(第二版)第十章serviceBestPractice,日志显示Handler和Looper中有错误

慕码人5336455 2019-06-05 07:40:16
E/AndroidRuntime: FATAL EXCEPTION: main    Process: com.example.servicebestpractice, PID: 14967    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)        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1737)        at android.os.Handler.dispatchMessage(Handler.java:106)        at android.os.Looper.loop(Looper.java:193)        at android.app.ActivityThread.main(ActivityThread.java:6669)        at java.lang.reflect.Method.invoke(Native Method)        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)求大神帮忙解释一下
查看完整描述

3 回答

?
浪里小神龙

TA贡献16条经验 获得超0个赞

原本的NotificationCompat.Builder (Context context)被废弃,在API26之后,创建通知需要使用新的构造器NotificationCompat.Builder (Context context, String channelId)

查看完整回答
反对 回复 2019-11-18
  • 3 回答
  • 0 关注
  • 1516 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信