2016-10-02 4 views
0

クラスを拡張したNotificationListenerServiceがあります。どうすればonNotificationPosted(StatusBarNotification sbn、RankingMap rankingMap)メソッドで大きな通知アイコンを取得できますか?NotificationListenerServiceで大きなアイコンを取得する方法

public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { 
    extras = sbn.getNotification().extras; 
    smallIcon = extras.getInt(Notification.EXTRA_SMALL_ICON, 0); 
... 
} 

、それはそのパッケージに描画可能のIDを返しますが、どのようにiが大きいアイコンを取得することができます:

は私が使う小さなアイコンを取得するには?

final Bitmap iconLarge = (Bitmap) extras.getParcelable(Notification.EXTRA_LARGE_ICON); 

final Bitmap iconLarge = sbn.getNotification().largeIcon; 

が常にのみ23+、私は動作しませ21+

sbn.getNotification().getLargeIcon() 

APIをターゲット、nullを返すこと: は、私はそのようななめらかを試してみました。 助けてください?

+0

これを解決しましたか?私は同じ問題があり、 'largeIcon'は非難されました。 – Mohammad

+0

はい、私は答えを加えました。 – kara4k

答えて

1

Androidのドキュメントによると、

getLargeIcon()方法は、APIレベルのみ23に追加されます。

APIを使用すると、Androidのロリポップ(APIレベル21)でそれにアクセスしようとマシュマロの場合は正常に動作しているときにnullを返している理由です(APIレベル23)解決

0

Bundle extras = sbn.getNotification().extras; 
Bitmap bigIcon = (Bitmap) extras.get(Notification.EXTRA_LARGE_ICON); 
+0

ありがとうございます。私はそれを試してみます :) – Mohammad

関連する問題