【发布时间】:2016-10-02 22:45:03
【问题描述】:
我有一个类扩展 NotificationListenerService,如何在 onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) 方法中获取大通知图标?
要获得我使用的小图标:
public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
extras = sbn.getNotification().extras;
smallIcon = extras.getInt(Notification.EXTRA_SMALL_ICON, 0);
...
}
它会返回该包中可绘制对象的 id,但我怎样才能获得一个大图标? 我是这样尝试的:
final Bitmap iconLarge = (Bitmap) extras.getParcelable(Notification.EXTRA_LARGE_ICON);
还有那个
final Bitmap iconLarge = sbn.getNotification().largeIcon;
它总是返回 null,我的目标是 API 21+
sbn.getNotification().getLargeIcon()
不工作,只有 23 岁以上。 有什么帮助吗?
【问题讨论】:
-
你解决了吗?我有同样的问题,
largeIcon已被弃用。 -
是的,我添加了一个答案,检查一下。
标签: android notifications icons