Notification Bar shows both Large and Small Icons

27,729

Solution 1

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());

Solution 2

Another issue i had in android lollipop is that the small icon was displayed next to the large icon. To solve it - just don't set the large icon! Use only the small icon setting.

Share:
27,729
D4N14L
Author by

D4N14L

Updated on March 16, 2020

Comments

  • D4N14L
    D4N14L about 4 years

    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?