I am trying to retrieve the icon displayed in a system notification, such as “Do Not Disturb turned on,” using NotificationListenerService. The notification comes from the package com.android.systemui, but it does not include a standard smallIcon or largeIcon in the Notification object.
Here’s what I have tried so far (all returns null):
// Extract large icon
val largeIconViaGetter = notification.getLargeIcon()
val largeIconViaExtra = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
extras.getParcelable(
Notification.EXTRA_LARGE_ICON_BIG, Bitmap::class.java
)
} else {
@Suppress("DEPRECATION")
extras.getParcelable(Notification.EXTRA_LARGE_ICON_BIG)
}
// Extract small icon
val smallIcon = notification.getLargeIcon()
Question:
How can I retrieve the icon shown in system notifications, such as “Do Not Disturb turned on”?
- Which field in the StatusBarNotification or Notification object contains this icon?
- How can I correctly load or convert it into a Drawable, Bitmap, or Icon?
Additional Information:
The package name of the notification is “com.android.systemui”. Icon of this package not the same as real “Do not disturb” icon