NotificationCompat v7和Android O

我在使用NotificationCompat v7和Android O时遇到了麻烦。由于NotificationCompatV7的实现只实现了v4版本的不赞成使用的构造函数( 在支持库26.0.0-beta1中已弃用 ),所以我无法使Notifications正常工作。

这里提出了NotificationCompat v4的解决方案: NotificationCompat with API 26

但是由于v7版本( https://issuetracker.google.com/issues/62475846 )的实施效果不佳,我无法在Android O上发布通知

有没有人有这个解决方案,或者我在这里错过了什么?

NotificationCompat v7现已被弃用,您应该使用NotificationCompat v4 (根据NotificationCompat v7类上的注释)。

/** * @deprecated Use the static classes in {@link android.support.v4.app.NotificationCompat}. */ 

那么你可以建立你的通知(Kotlin):

 val notificationBuilder = NotificationCompat.Builder(context, "your_notification_channel_name") .setContentTitle("title") [...] 

注意:最新的支持版本是“com.android.support:appcompat-v7:26.0.0”