I know there are a lot of questions like mine, but I really need to solve it. As far as I know in API level 23 , Android has introduced new method to setSmallIcon using bitmap. So, I can use Bitmap
to set it in notification. The reason why I can't use Drawables
as well as RemoteViews
is no possibilies to have resources in my library(JAR). All icons and bitmaps are stored in Base64
format(They are small). Is there a quick way to add new setSmallIcon
implementation to older version of Notification. Thanks.
Asked
Active
Viewed 297 times
-1
1 Answers
1
Is there a quick way to add new setSmallIcon implementation to older version of Notification.
Not only is there no quick way, there is no way at all.
API 23 introduced a new Icon
class which can be supplied to Notification.Builder.setSmallIcon(Icon)
. This object can be created from
- Bitmap
- URI pointing to an image
- Image file path
- Resource ID pointing to a drawable
- Byte array
This Icon
class is not present below API 23 and the only way to set a small icon to a notification is to use Notification.Builder.setSmallIcon(int)
which takes a drawable resource ID as parameter.
Consider migrating from .jar to .aar.

Eugen Pechanec
- 37,669
- 7
- 103
- 124
-
Why? Is it have a lot of dependencies? – Nolesh Feb 16 '16 at 13:35
-
is there a way to setSmallicon from byte arrays? – SHM Aug 08 '16 at 12:09
-
@EugenPechanec i asked about api 19. – SHM Aug 08 '16 at 12:12
-
@SHM And how am I supposed to know if you don't write it? Besides, did you read the answer? It already explains it's not possible, sorry. – Eugen Pechanec Aug 08 '16 at 12:15
-
@EugenPechanec you should know that, because i commented below your answer which already states "api 23". – SHM Aug 08 '16 at 12:25
-
@SHM The last paragraph: "This **Icon class is not present ***below*** API 23** and the **only way to set a small icon to a notification is to use** Notification.Builder.setSmallIcon(int) which takes **a drawable resource ID** as parameter." How is that not clear? – Eugen Pechanec Aug 08 '16 at 13:03