It is possible to set a custom icon for push notifications in Android, by using Android's custom notification icon functionality.
In order to use this functionality, a new method can be used when creating the
PushConnector instance, e.g:
mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER") .setIcon("iconfilenamewithoutextension") .create(this);
This will set the icon for the notifications with an image from the
res/drawable folder of the app. In this example, the library will try to look for a file called
iconfilenamewithoutextension.png etc. in the
res/drawable folder. If the file cannot be found, the default app icon will be used instead.
If you do set an icon, the library will also search for a color entry with the same name in one of the XML files in the
res/values to use as a background colour behind the icon. This entry could look like the following:
<!-- color int as #AARRGGBB (alpha, red, green, blue) --> <color name="iconfilenamewithoutextension">#ff2266ff</color>
On Android 5.0 and later you are encouraged to set an icon that is in keeping with their design guidelines (icons should be white only and have transparent sections for a background colour to show through).
So on any Android device running android 5 or later, if your notification icon is not set, the icon in the notification will show as a white square as shown below:
Updated about 2 years ago