如何区分两条WhatsApp消息?

时间:2017-10-19 12:26:06

标签: android notifications

首先,我是如何从通知中读取WhatsApp消息的?

好吧,我研究过并且能够实现具有适当权限的NotificationListenerService没有任何卑鄙的策略)并收听来自WhatsApp的通知消息。感谢this guy给我这个想法。

无论如何,我现在能够阅读消息,但问题是WhatsApp有时会多次发送相同的消息,但不会显示多个通知。我怎么知道?

我记录了听众收到的通知,发现了几条相同的消息。通知的一般结构如下所示:

StatusBarNotification.toString():

> 10-18 23:43:24.236 16159-16181/com.company D/WhatsApNotifListService:
> StatusBarNotification(pkg=com.whatsapp user=UserHandle{0} id=1
> tag=null score=0 key=0|com.whatsapp|1|null|10170: Notification(pri=0
> contentView=com.whatsapp/0x1090078 vibrate=null sound=null
> defaults=0x0 flags=0x200 color=0xffe65100 category=msg
> groupKey=group_key_messages vis=PRIVATE
> publicVersion=Notification(pri=0 contentView=com.whatsapp/0x1090078
> vibrate=null sound=null defaults=0x0 flags=0x0 color=0xffe65100
> category=msg vis=PRIVATE)))

Notification.extras(A Bundle)结构:

> 10-18 23:42:46.199 16159-16211/com.company D/Util: android.title
> Manish (java.lang.String)
> 
> 10-18 23:42:46.199 16159-16211/com.company D/Util: android.subText
> null (null)
> 
> 10-18 23:42:46.201 16159-16211/com.company D/Util:
> android.car.EXTENSIONS Bundle[mParcelledData.dataSize=1852]
> (android.os.Bundle)
> 
> 10-18 23:42:46.201 16159-16211/com.company D/Util:
> android.showChronometer false (java.lang.Boolean)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.icon
> 2130840435 (java.lang.Integer)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.text Bdbdjd
> (java.lang.String)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.progress 0
> (java.lang.Integer)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.progressMax
> 0 (java.lang.Integer)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.showWhen
> true (java.lang.Boolean)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util:
> android.rebuild.applicationInfo ApplicationInfo{1a7615bc com.whatsapp}
> (android.content.pm.ApplicationInfo)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.largeIcon
> android.graphics.Bitmap@a4eb945 (android.graphics.Bitmap)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util: android.infoText
> null (null)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util:
> android.wearable.EXTENSIONS Bundle[mParcelledData.dataSize=668]
> (android.os.Bundle)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util:
> android.originatingUserId 0 (java.lang.Integer)
> 
> 10-18 23:42:46.202 16159-16211/com.company D/Util:
> android.progressIndeterminate false (java.lang.Boolean)

有没有像Id这样的东西或者可以提取的东西来区分两条消息?

1 个答案:

答案 0 :(得分:1)

我无法相信我解决了我的问题。时间戳就是答案。由于建议时间,因此会转到@xenolion。我的想法是关于时间不同的先入为主的想法,但我只是检查了消息的时间戳,而相同的消息具有相同的时间戳。

相关问题