Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android NotificationListenerService不包括额外的人员列表_Android - Fatal编程技术网

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列表。