Enlarged, cropped notification icon

I am creating a notification using NotificationCompat.Builder. To install most of the icon, I use this:

bob = new NotificationCompat.Builder(context)
 .setLargeIcon(bm)
 .setAutoCancel(true)
 .setSmallIcon(R.drawable.ic_launcher256)
 .setContentTitle(context.getResources().getString(R.string.app_name))
 .setContentText(message)
 .setPriority(Notification.PRIORITY_HIGH);

The small character displays well, but on some devices the large icon scales and therefore is cropped. On other devices (conveniently, everything I can check for) it works fine.

I do not know any restrictions on the size of this icon. It leaves the user contact list, so I can’t control what happens there, although, I suppose, I could resize / reformat it if this were a problem.

I will continue to debug this (focusing on the logic that gets the bitmap), but I thought I would ask if I missed something (un) obvious. Perhaps people can set contact photos on their devices that are not suitable for notifications without prior processing.

+3
source share
1 answer

This is not documented .: (

From the main template of the template, you can see that the icon has just plunged into ImageViewc android:scaleType="center", so nothing more than the field ( @dimen/notification_large_icon_widthx @dimen/notification_large_icon_height) will simply be cut off, because it will overflow its borders.

, dimens.xml, 64x64dp. , .

+7

All Articles