Notification Bar shows both Large and Small Icons

D4N14L picture D4N14L · Jun 14, 2012 · Viewed 27.6k times · Source

The notification bar in my application shows only the small icon in the ticker (as it should). However, when the "shade" is pulled down, it shows both the small icon from the ticker, as well as a large icon that I set in the Notification.Builder. Here's my code:

if (Build.VERSION.SDK_INT > 10){
            notification = new Notification(R.drawable.ic_stat_mintchip,
                    "This is a test",
                    System.currentTimeMillis());
            notification.largeIcon = (((BitmapDrawable)c.getResources().getDrawable(R.drawable.ic_launcher)).getBitmap());
            notification.defaults |= Notification.DEFAULT_ALL;
            notification.number += 1;
            notification.flags |= Notification.FLAG_AUTO_CANCEL;

        } else {
            notification = new Notification(R.drawable.ic_stat_mintchip,
                    "This is a test",
                    System.currentTimeMillis());

                notification.flags |= Notification.FLAG_AUTO_CANCEL;
                notification.defaults |= Notification.DEFAULT_ALL;
                notification.number += 1;
        }
}

I don't quite know why this is happening. Any assistance?

Answer

afollestad picture afollestad · Jul 2, 2012

I think the issue here is possibly that you're not using the Notificaiton.Builder class. Here's a small example of what you could do (you would have to insert your own variables though, and set the other properties that you used such as vibration):

Notification.Builder nb = new Notification.Builder(context)
    .setContentTitle("title")
    .setContentText("content")
    .setAutoCancel(true)
    .setLargeIcon(largeIcon)
    .setSmallIcon(R.drawable.small_icon)
    .setTicker(s.getText());
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(100, nb.build());