综合技术

NotificationCompat.setStyle () can not receive Notification.MediaStyle

微信扫一扫,分享到朋友圈

NotificationCompat.setStyle () can not receive Notification.MediaStyle
0

I’ve found out that the MediaStyle setStyle is not working when I’m using NotificationCompat.builder(this)
to make a notification.

I mean, When using this on NotificationCompat.Builder(this)
:

.setStyle(new Notification.MediaStyle()
         .setMediaSession(mySession))

It saying it wants to get NotificationCompat.style
instead of Notification.MediaStyle
.

Can you help me solve that problem? Is there any replacement for the NotificationCompat?

Thanks.

There is no NotificationCompat.MediaStyle
in v4 package, however, it does exist in v7 package. Make sure to import:

import android.support.v7.app.NotificationCompat;

instead of the v4 package. It’s working for me as of v22.2.0 of the appcompat library.

EDIT: as of version 26.0.0, the v7 package is deprecated
. However, all functionality has been added to v4! Yay!

阅读原文...


Hello, buddy!

Kafka入门之旅

上一篇

使用机器学习预测房价(附链接)

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
NotificationCompat.setStyle () can not receive Notification.MediaStyle

长按储存图像,分享给朋友