6

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?

CMA
  • 2,758
  • 5
  • 28
  • 40
D4N14L
  • 440
  • 1
  • 6
  • 10
  • 1
    Can you post a screenshot somewhere of what you are seeing? – CommonsWare Jun 14 '12 at 00:23
  • Sure, one second... http://imgur.com/07lxg – D4N14L Jul 01 '12 at 23:15
  • 1
    I assume that you are MintChip. I am not quite certain why you are getting that effect. What device is this? Note that while your question says you are using `Notification.Builder`, your code is not. You might consider using `NotificationCompat.Builder` from the Android Support project and see if that helps. – CommonsWare Jul 01 '12 at 23:18

3 Answers3

11

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());
afollestad
  • 2,929
  • 5
  • 30
  • 44
  • 1
    I can't compile the 'nb.build()' in Android4.04, I use nb.getNotification() instead. – herbertD Dec 31 '12 at 14:51
  • if i use a ticker text, which icon is used for it? and how can i customize it and use a different one for it and a different one for the notification itself? – android developer Oct 15 '13 at 10:25
  • @androiddeveloper the small icon is shown in the status bar, the large icon is shown when you open the notification shade. – afollestad Dec 16 '13 at 14:58
  • @afollestad is it possible to have a different icon for the ticker text and a different one for the notification? – android developer Dec 16 '13 at 17:19
  • 1
    With above code if i set both small and large icons notification is displaying both small and large icon when user pull the notification. Running with below configuration. any solution for this? – ashok reddy Dec 03 '16 at 13:49
7

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.

ravyoli
  • 698
  • 6
  • 13
0

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html if you set your max sdk version in android manifest to 19(i.e KitKat) Your app will no longer display notifications meant for lolipop