Android通知未在API 26上显示

前端之家收集整理的这篇文章主要介绍了Android通知未在API 26上显示前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近将我的应用更新为API 26,并且通知不再有效,甚至没有更改代码.
val notification = NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_notification)
                .setContentTitle("Title")
                .setContentText("Text")
                .build()
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).notify(1,notification)

为什么不工作?是否有一些我不知道的API变化?

解决方法

the documentation开始:

Android O introduces notification channels to provide a unified system to help users manage notifications. When you target Android O,you must implement one or more notification channels to display notifications to your users. If you don’t target Android O,your apps behave the same as they do on Android 7.0 when running on Android O devices.

(重点补充)

您似乎没有将此通知与频道相关联.

原文链接:https://www.f2er.com/android/316675.html

猜你在找的Android相关文章