Question

My notification icons become large on the notification alert and shows up properly later. Wht is the notification icon size that needs be dispalyed?

check both the icons:

This is shown when I get a new message. The icon is bigger and not good.

enter image description here

This is shown after new message alert is shown. Looks good.

enter image description here

Why can't I get the same size image icon when an new message alert comes up? Is there a size difference?

Below is the code I am using to show notification:

Intent notificationIntent = new Intent(context, Sms.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK));

NotificationManager nm = (NotificationManager)   
context.getSystemService(Context.NOTIFICATION_SERVICE);
Resources res = context.getResources();
Notification.Builder builder = new Notification.Builder(context);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.newyellowsms)
.setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.smsnotification))
.setTicker(res.getString(R.string.ticker))
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(address)
.setContentText(body);
Notification n = builder.build();
nm.notify(007, n);

The R.string.ticker has the "New Message" string.

Was it helpful?

Solution

Your small icon size will be 24 x 24 set and check Notification.

OTHER TIPS

Notification icons must be 24x24 dp. please refer this doc http://developer.android.com/design/style/iconography.html

Thanks Jay and Sanket Kachela.

I thought 24 dp is 24 px.

ldpi @ 24.00dp = 18.00px

mdpi @ 24.00dp = 24.00px

hdpi @ 24.00dp = 36.00px

xhdpi @ 24.00dp = 48.00px

After changing according to the above PX size notification is showing up properly.

Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top