The notification bar shows both large and small icons

The notification panel in my application shows only a small icon in the ticker (as it should). However, when the β€œshadow” is reset, it shows both the small icon from the ticker and the large icon that I set in Notification.Builder. Here is 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 do not quite understand why this is happening. Any help?

+6
source share
3 answers

I think the problem here is probably that you are not using the Notificaiton.Builder class. Here is a small example of what you could do (you have to insert your own variables, as well as set 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()); 
+11
source

Another problem that I encountered in android lollipop is that a small icon was shown next to a large icon. To solve this problem - just do not install the large icon! Use only a small icon setting.

+7
source

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

0
source

Source: https://habr.com/ru/post/918044/


All Articles