无法在频道上发布通知“null”目标Api是26 [英] Failed to post notification on channel "null" Target Api is 26

查看:1175
本文介绍了无法在频道上发布通知“null”目标Api是26的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个日志显示



1:对于音量控制以外的操作,不推荐使用流类型

2:请参阅setSound()的文档以代替使用android.media.AudioAttributes来限定您的播放用例

解决方案

如果遇到这个错误,应该注意3个项目:


  1. builder = new NotificationCompat.Builder(this,name);


  2. builder.setChannelId(id)// Android 8需要Oreo API 26及更高版本


错误的原因不符合所有三个要素。



只有必要的setter

  builder.setContentTitle()//必需
.setSmallIcon在Android 8 Oreo API 26及更高版本上的通知列表()//需要
.setContentText()//需要
.setChannelId(id)//在Android 8上需要Oreo API 26及更高版本

请参阅在Android 8上,奥利奥API 26和更高版本的通知不会显示


Two log showing

1: Use of stream types is deprecated for operations other than volume control

2: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case

解决方案

If you get this error should be paid attention to 3 items:

  1. builder = new NotificationCompat.Builder(this, name);

  2. NotificationChannel mChannel = new NotificationChannel(id, name, importance);

  3. builder.setChannelId(id) // required for Android 8 Oreo API 26 and later

The reason for the error not in compliance with all three elements.

There are only required setters list for Notification on Android 8 Oreo API 26 and later:

builder.setContentTitle() // required  
       .setSmallIcon()    // required 
       .setContentText()  // required  
       .setChannelId(id)  // required on Android 8 Oreo API 26 and later

See the example in On Android 8 Oreo API 26 and later notification does not display.

这篇关于无法在频道上发布通知“null”目标Api是26的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆