gpt4 book ai didi

java - Android:将 Person 与 NotificationCompat 结合使用

转载 作者:行者123 更新时间:2023-11-30 05:02:58 25 4
gpt4 key购买 nike

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

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

有什么方法可以将 Person 类与 NotificationCompat 一起使用吗?

这就是我想要做的:

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 实现同样的效果?

最佳答案

解决方案是使用AndroidX而不是 Android 支持库,因为后者不再更新。

关于java - Android:将 Person 与 NotificationCompat 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57901566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com