The question is how to get the TEXT field (not the header) of all incoming notifications when they fit (for example, into Whatsapp).

public class NLService extends NotificationListenerService { public void onNotificationPosted(StatusBarNotification sbn) { Log.v(Constants.TAG_notifs, "------------------------- in onNotificationPosted(), Notification Text = " + sbn.getNotification().tickerText); Bundle extras = sbn.getNotification().extras; if (extras.containsKey("android.text")) { if (extras.getCharSequence("android.text") != null) { String text = extras.getCharSequence("android.text").toString(); Log.v(Constants.TAG_notifs, "------------------------- in onNotificationPosted(), Bundle.text != NULL, so here it is = " + text); } } if (extras.containsKey("android.title")) { Log.v(Constants.TAG_notifs, "------------------------- in onNotificationPosted(), Bundle android.title = " + extras.getString("android.title")); } } @Override public void onNotificationRemoved(StatusBarNotification sbn) {
} The first time a Whatsapp notification comes from one user, this line ( String text = extras.getCharSequence ("android.text"). ToString (); ) can read the text successfully, but after that, when more messages arrive, and notifications become complex (for example, in the figure above), the variable text is always NULL.
This should be possible because this application does this, tested it. It receives the text of each application.
Added incentive: if you know the answer or try something, another question arises, which looks like a similar question here .
android android-notifications
user1406716
source share