2

I'm using NotificationListenerService to listen for notifications.

When I receive a notification, I extract the title and message using the following code:

Bundle n = sbn.getNotification().extras;
String title = n.getString(Notification.EXTRAS_TITLE);
String message = n.getString(Notification.EXTRAS_TEXT);

The problem is when I receive a notification with BigTextStyle.

How do I retrieve its value?

Thanks.

Maurício Giordano
  • 3,116
  • 4
  • 32
  • 60

1 Answers1

0

From what I see in the documentation, you can do:

Bundle n = sbn.getNotification().extras;
String title = n.getString(Notification.EXTRAS_TITLE);
String message = n.getString(Notification.EXTRAS_TEXT);
String bigText = n.getString(Notification.EXTRA_BIG_TEXT);

Reference: https://developer.android.com/reference/android/app/Notification.html#EXTRA_BIG_TEXT

Christian Göllner
  • 5,808
  • 4
  • 19
  • 20
  • Note: at least in some scenarios, `getString(Notification.EXTRA_BIG_TEXT)` returned null for me. Instead, try using this: `n.get(Notification.EXTRA_BIG_TEXT) == null ? null : n.get(Notification.EXTRA_BIG_TEXT).toString();` – Yoav Feuerstein Sep 19 '17 at 14:59