Getting verbose / extended text from Android notifications?

I implemented a notification listener to view a Gmail notification.

I want to collect extended text (large text) from a notification, as shown in the notification below:

Expanded text shown in gmail notification

See "---- Forwarded Message ---" etc., which appears only when the user expands the notification to display action buttons.

This string value does not appear in the EXTRAS notification data ...

http://developer.android.com/reference/android/app/Notification.html

+2
source share
3 answers

(EXTRAS). , , , , ,

notifyBundle.extras.getCharSequence("android.textLines")

notifyBundle.extras.getString("android.text") .

eclipse

. API19 (Kitkat). , API19.

+4

, , .

ArrayList<StatusBarNotification> 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);

getCharSequence("android.textLines"), null, NotificationCompat.EXTRA_TEXT_LINES CharSequence, CharSequence.

+1

Gmail, Android 7.

, ( ), - , , -:

Bundle extras = statusBarNotification.getNotification().extras; extras.get(Notification.EXTRA_BIG_TEXT) == null ? null : extras.get(Notification.EXTRA_BIG_TEXT).toString();

This way you always get either String or null, even if the value you are looking for is not initially a string. This is because the call getString(Notification.EXTRA_BIG_TEXT)will directly return null, at least in some cases.

If there are other values, you do not know where they can be saved, you can try to iterate through the whole set of additional services as described here .

+1
source

Source: https://habr.com/ru/post/1544598/


All Articles