如何为较低的API(< 26)创建NotificationChannel?

时间:2017-09-29 07:02:31

标签: android notifications android-notifications android-appcompat notification-channel

如何为较低的API(< 26)?创建NotificationChannel。有没有办法用AppCompat做到这一点?

1 个答案:

答案 0 :(得分:5)

不可能。 Android操作系统不支持它。您可以使用NotificationCompat.Builder(Context context, String channelId)将channelId添加到通知中,但操作系统会在Oreo之前忽略它。

我的同事在API 15,22,23和26上对其进行了测试:https://stackoverflow.com/a/45979726/1310343