Android NotificationListenerService不包括额外的人员列表
正在尝试从Android NotificationListenerService不包括额外的人员列表,android,Android,正在尝试从NotificationListenerService上收到的MessagingStyle通知中读取通知。额外人员列表,如下所示: ArrayList<Person> people = sbn.getNotification().extras.getParcelableArrayList(Notification.EXTRA_PEOPLE_LIST); ArrayList people=sbn.getNotification().extras.getParcelableA
NotificationListenerService
上收到的MessagingStyle
通知中读取通知。额外人员列表
,如下所示:
ArrayList<Person> people = sbn.getNotification().extras.getParcelableArrayList(Notification.EXTRA_PEOPLE_LIST);
ArrayList people=sbn.getNotification().extras.getParcelableArrayList(Notification.EXTRA_people_LIST);
获取总是空的
打印sbn.getNotification().extras.keySet()
我可以看到EXTRA\u PEOPLE\u LIST=“android.PEOPLE.LIST”
键确实不在那里,但根据它应该在那里
我在小米设备和Pixel2模拟器上进行了尝试,两者都运行Android 9(API 28)
我的代码有问题吗?完全独立于MessagingStyle
,因此您可能会看到实现MessagingStyle
但实际上没有添加任何人员的应用程序,这就解释了为什么额外人员列表
为空
如果您特别查找通知的
MessagingStyle
部分中提到的人员,则需要使用从通知中获取MessagingStyle
对象。之后,您可以调用getMessages()
并从那里获取联系人。是否返回非空对象?请注意,这是完全独立于MessagingStyle
-不要求应用程序开发人员同时使用这两种样式。感谢@ianhanniballake的评论。它返回一个非空对象。我从getMessages()
的Message
s列表中获得了Person
s列表。