我试图将一个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()
答案 0 :(得分:0)
根据文档,它也接受Person作为参数:
NotificationCompat.Builder.addPerson(person)
如图here
使用compat / androidX库来支持OS实现始终是更好的选择,因为它们具有完全的向后兼容性(如果可能)。