Reputation: 4155
I'm actually using PushBots to implement GCM notifications for my application.
They give me the option, when I create the notification, to use a specific field where I can set the largeIcon
for my push. If I use that, I get something like this:
But, if I dont use that, I get this:
I would like to know if is it possible to set a default smallIcon
and largeIcon
for every notification (push) that my app recieve or change that white box that appears for my own app icon.
1- Note: I don't create the notification in my code, I create it in the PushBots website Drashboard.
2- Note: largeIcon
and smallIcon
Thanks.
Upvotes: 1
Views: 5264
Reputation: 4155
Finally, after hours looking the source code of PushBots, I just found out a solution.
In Android Studio, go to File -> New -> Image Asset
. Then, choose Notification Icon
. Now customize your new small Icon and, before finish it, put the name white_notification_icon
for this new asset.
Android Studio will say to you that the file already exists and it is going to be overwritten. Say yes.
Now, you have a smallIcon by default already set!
Upvotes: 3
Reputation: 800
Please refer following code
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(R.drawable.small_notification);
mBuilder.setLargeIcon(BitmapFactory.decodeResource(getBitmapFromURL("YOURURL"));
if (version >= 23) {
mBuilder.setColor(ContextCompat.getColor(this, R.color.black));
} else {
mBuilder.setColor(this.getResources().getColor(R.color.black));
}
As per guide line small icon is compulsory and should be in white color or in gray color with alpha back ground refer this answer for more details
Upvotes: 0