Android:使用NotificationCompat中的Person

3
我想使用 AndroidPerson 类来创建一个发送者的 notification,以便在 Android P 中的 MessagingStyle 通知中显示用户图像。

然而,NotificationCompat.MessagingStyle 类不支持使用 Person 类,它似乎仅由 Notification.MessagingStyle 支持(请参见 addMessage 方法)。

是否有任何方法可以与 NotificationCompat 一起使用 Person 类?

这就是我想做的:

NotificationCompat.MessagingStyle msgStyle = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(notification); 

Person.Builder builder = new Person.Builder().setName(name).setIcon(icon);

msgStyle.addMessage(message, System.currentTimeMillis(), builder.build());

如果没有的话,我需要使用NotificationCompat.MessagingStyle类,因为我正在使用方法“extractMessagingStyleFromNotification”来保留通知中现有的消息,这样我只需要添加新消息。是否有办法使用Notification.MessagingStyle实现相同的效果?
1个回答

1
解决方案是使用AndroidX而不是Android Support Library,因为后者已不再更新。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接