I\'ve implemented a notification listener to look out for a Gmail notification.
I want to collect the expanded text (bigtext) from the notification as shown in the n
Finally, I am able to solve this issue by using this code.
ArrayList groupedNotifications = new ArrayList<>();
for(StatusBarNotification statusBarNotification : mNotificationManager.getActiveNotifications()) {
if(statusBarNotification.getNotification().getGroup().equals(NOTIFICATION_GROUP)) {
groupedNotifications.add(statusBarNotification);
}
}
CharSequence stackNotificationMultiLineText[] = groupedNotifications.get(ZEROTH_INDEX).getNotification().extras.getCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES);
If you try to use getCharSequence("android.textLines")
, it returns you null because NotificationCompat.EXTRA_TEXT_LINES
returns you the array of CharSequence
and not a single CharSequence
object.