Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification Bar shows both Large and Small Icons

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?

like image 963
D4N14L Avatar asked Jun 13 '12 22:06

D4N14L


People also ask

How do I expand my notification bar?

By default, if you see a notification icon in the notification bar that you want to see more about, swipe down once from the top of your screen to expand your notifications.

How do I change my notification icons?

1 Tap Notification Settings on the notification panel or tap the Settings app. 2 Tap Notifications. 3 Tap App icon badges.

How do I get rid of status bar notification icons?

Even if you don't get the gear icon when you swipe an Android Status Bar Icon notification, you can still turn off notifications for any app. Here's how: Go to Settings. Tap Notifications > App Settings.

How do I reduce notification size on android?

Select the gear icon to go to the system settings. Now go to the “Display” settings. Look for “Display Size” or “Screen Zoom.” Slide the dot on the scale at the bottom of the screen to adjust the size.


2 Answers

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());
like image 75
afollestad Avatar answered Sep 30 '22 16:09

afollestad


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.

like image 35
ravyoli Avatar answered Sep 30 '22 15:09

ravyoli