The question is how to get the TEXT (not title) field of all incoming notifications when they get stacked (like in Whatsapp).
If you're working with Android 7.0+, WhatsApp uses MessageStyle Expanded Notifications. Here - https://developer.android.com/training/notify-user/expanded.html#message-style
To retrieve all 5 messages from a notification like
MyFriend (5 messages)
testt
Do this:
Bundle extras = mysbn.getNotification().extras;
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)){
Parcelable b[] = (Parcelable[]) extras.get(Notification.EXTRA_MESSAGES);
if(b != null){
content = "";
for (Parcelable tmp : b){
Bundle msgBundle = (Bundle) tmp;
content = content + msgBundle.getString("text") + "\n";
/*Set io = msgBundle.keySet(); // To get the keys available for this bundle*/
}
}
}
Same as my answer here.