gpt4 book ai didi

android - 将人添加到NotificationCompat.Builder

转载 作者:行者123 更新时间:2023-12-02 13:40:27 25 4
gpt4 key购买 nike

我试图将一个Person添加到NotificationCompat中,但它只包含字符串。那在Notification上是不同的。如Android: Using Person with NotificationCompat中所述,应使用AndroidX。现在让我感到困惑的是,NotificationCompat具有数据包androidx.core.app,而Notification具有android.app。是否有其他接受Person的AndroidX类?提前致谢

val person = Person.Builder()
.setName("John")
.build()

NotificationCompat.Builder(context, someId)
.addPerson(person) // only accepts string
...
.build()

最佳答案

根据文档,它也接受Person作为参数:NotificationCompat.Builder.addPerson(person)如图所示here
最好使用compat / androidX库来支持OS实现,因为它们具有完全的向后兼容性(如果可能)。

关于android - 将人添加到NotificationCompat.Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64049500/

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