CookieMonssster
CookieMonssster

Reputation: 658

Getting Data from Notification

I am wiriting application and I don't know how to get data from Notification. I have NotificationListenerService (like this) and when new Notification occurs I recieve StatusBarNotification object. Anyone know how to take Title and Content of notification from this object (in tutorial is only tickerText)?

Upvotes: 1

Views: 714

Answers (1)

CookieMonssster
CookieMonssster

Reputation: 658

Ok, I fount simple way to do it, but it is available on android 19+ (KitKat 4.4.2):

If you want for example title of Notification, you can use something like this:

String title = sbn.getNotification().extras.getString(Notification.EXTRA_TITLE);

There is more information in extras, like text, prgress, time etc. - details here

sbn object is StatusBarNotification class object (the way how to reach this you can find in this tutorial

If you need to do it on earlier version of Android you have to try any answer from this topic.

Upvotes: 1

Related Questions