简体   繁体   English

如何在 Lollipop 中设置通知图标?

[英]How to set notification icon in Lollipop?

I can not get an app_icon in the notification bar.我无法在通知栏中获得 app_icon。
I want to set my app icon in notification icon.我想在通知图标中设置我的应用程序图标。
How can I do this?我怎样才能做到这一点?

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(icon); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(icon);

I got White icon instand of app icon我得到了应用程序图标的白色图标

I had the same issue, mainly it happens with the issue of not suporting sizes.我有同样的问题,主要是因为不支持尺寸的问题。 hope this might help.希望这可能会有所帮助。

Notification noti = new NotificationCompat.Builder(context)
                .setContentTitle("DPD News")
                .setSmallIcon(R.drawable.YOURICON_SMALL) // this is the icon that show in notification are before drage down, small icon. this has to be 25px X 25px
                .setLargeIcon(LARGE_ICON) // i have use the same sizes of ic_launcher to this
                .setContentText("MESSAGE")
                .setContentIntent(pi)  // pending intent if needed
                .setAutoCancel(true)
                .build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM