java - Android:使用带有 NotificationCompat 的 Person
问题描述
我想使用Android
'sPerson
类来创建 a 的发送者,notification
以便用户图像显示MessagingStyle
在Android P
.
但是,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 Support Library,因为后者不再更新。
推荐阅读
- apache-spark - org.apache.spark.SparkException: Job aborted due to stage failure: Task in stage failed,Lost task in stage : ExecutorLostFailure (executor 4 lost)
- go - 为什么 go 测试突然需要“gcc”?
- node.js - PM2 + Winston 日志管理
- javascript - 如何预测 HTML 元素的宽度以便在不透明度和宽度上进行 CSS 过渡?
- angular - 如何从请求中返回 HttpClient 响应正文?
- java - 助手类中的计算问题 - 在计算之前返回
- javascript - 如何在服务器上以 SPA 模式正确部署 Nuxt.js?
- java - 为 ant spotbugs 编辑 build.xml
- c# - 扩展属性不遵守 EmailMessage
- android - 我在颤振中实现以下设计时遇到问题