You can try this to see if it works with Facebook messenger notifications. And even if this does work, I would suggest that you wait for a better solution.
From API 19 and above, Notification
objects carry bundled extras
- the inputs passed to Notification.Builder
when the Notification
was first created. So, information such as the title
, context
, summary
etc. can be extracted from this Bundle
using keys of form Notification.EXTRAS_XXXX
. The keys can be found here: Link.
In the overriden onAccessibilityEvent(AccessibilityEvent event)
method:
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Parcelable data = event.getParcelableData();
if (data != null && data instanceof Notification) {
Log.i("", "We have a notification to parse");
Notification notification = (Notification) data;
// For API 19 and above, `Notifications` carry an `extras` bundle with them
// From this bundle, you can extract info such as:
// `EXTRA_TITLE` - as supplied to setContentTitle(CharSequence)
// `EXTRA_TEXT ` - as supplied to setContentText(CharSequence)
// `EXTRA_INFO_TEXT` - as supplied to setContentInfo(CharSequence)
// ... more at: http://developer.android.com/reference/android/app/Notification.html
Bundle b = noti.extras;
Log.i("Notification", "Title: " + b.get(Notification.EXTRA_TITLE));
Log.i("Notification", "Text: " + b.get(Notification.EXTRA_TEXT));
Log.i("Notification", "Info Text: " + b.get(Notification.EXTRA_INFO_TEXT));
/////////////////////////////////////////////////////////////////
// For API 18 and under:
// Pass `notification` to a method that parses a Notification object - See link below
List<String> notificationText = extractTextFromNotification(notification);
....
....
}
}
extractTextFromNotification(Notification)
can be a method from here: Link. Needless to say that this is a workaround, and will require quite a bit of testing to ensure that it works as required.