In a Service extending the new (SDK18, JB-4.3) NotificationListenerService
, I'd like to get the Notification's status bar icon.
mStatusBarNotification.getNotification().icon
returns the resource id of the status bar drawable, but that resource id is naturally not within my app's scope/resources. There's also mStatusBarNotification.getNotification().largeIcon
(returning a Bitmap
), but that's not set for all notifications and returns the "wrong" icon (the image in the expanded notification drawer).
Use getPackageName()
on StatusBarNotification
to find out the app that posted the Notification
. You can then use createPackageContext()
to get a Context
for that package, then use that Context
to retrieve the image (e.g., via getResources()
).