2

I would like to use an icon via a url as opposed to an already included drawable. Is this possible? The only method signature for setSmallIcon accepts an int for a Drawable resource.

However, what can I do if I want to include a smallIcon in the push notification that I'm sending? (Let's say for instance another user's gravatar).

JabberwockyDecompiler
  • 3,318
  • 2
  • 42
  • 54
StackOverflowed
  • 5,854
  • 9
  • 55
  • 119
  • 1
    AFAIK, what you are seeking is not supported. The user image is the large icon, not the small one, in Android's model. – CommonsWare May 07 '15 at 20:47

1 Answers1

1

No, you cannot set a custom smallIcon for a notification, as per the documentation and training section. However, as CommonsWare commented, you can set a custom largeIcon. This type of icon is shown when the user expands the notification panel, or on the "heads-up" notifications in Android 5.0+ (when the priority is at least HIGH). This can be done by calling setLargeIcon(myBitmap) on your Notification.Builder object. myBitmap can be any Bitmap object, loaded from the internet or otherwise.

I believe the reasoning behind this is so that the user can always quickly identify which apps are trying to notify them. Otherwise, the user would have to try to figure out what each new icon meant when just quickly checking notifications.

T3KBAU5
  • 1,861
  • 20
  • 26