I'm trying this code,
NotificationCompat.Builder nfBuilder = new NotificationCompat.Builder(
context)
..setContentTitle(
"XYZ")
.setContentText("ABC")
.setContentIntent(pIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setOnlyAlertOnce(true)
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
.setSmallIcon(R.drawable.woj_ic_launcher);
Notification notification = nfBuilder.build();
NotificationManager nfManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
nfManager.notify(requestCode, notification);
Problem is, it works fine with all other platforms but with lollipop, it shows very small icon with grey circle around it. I tried changing icon sizes and using setLargeIcon() method but still no joy.
The image should have square proportion. Use this tool (https://romannurik.github.io/AndroidAssetStudio/icons-notification.html) and then make sure you use the "Api v11" icons, since they have the square proportion you need, the older version had a little more height.
Recap: I got to tell I don't really see you icon being too small, in fact that's the greatest icon size I could get, look..
And for the "grey" background issue, is something like Notification.Builder.setColor(Color.RED) not working for you?
This is how it sorted out finally:
NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(getApplicationContext());
nBuilder.setContentTitle("notificationTitle");
nBuilder.setSmallIcon(R.mipmap.ic_launcher);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher1);
nBuilder.setLargeIcon(bitmap);
nBuilder.setContentText(notificationText);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, nBuilder.build());
setLargeIcon(Bitmap bitmap)
method of NotificationCompat.Builder
.Note:setSmallIcon()
is a mendatory method here. You can't skip it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With