gpt4 book ai didi

Android通知状态栏和通知正文的不同图标

转载 作者:行者123 更新时间:2023-11-29 00:22:15 25 4
gpt4 key购买 nike

我收到电池电量通知。我想在状态栏和通知中心制作不同的图标。在状态栏中:数字(2 位数字)。在正文中:我的应用程序图标。我怎样才能做到这一点?应用程序图标也在状态栏中,我该如何更改?

最佳答案

我不确定您的代码现在是什么样子,但我会这样做:

Notification.Builder nb = new Notification.Builder(context)
.setContentTitle("title")
.setContentText("content")
.setAutoCancel(true)
.setLargeIcon(R.drawable.large_icon)
.setSmallIcon(R.drawable.small_icon)
.setTicker("ticker text");
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(100, nb.build());

注意 setLargeIcon()setSmallIcon()。您要在“自动收报机”中显示的图标应该在 setSmallIcon() 中设置,对于您所谓的“通知中心”,您应该使用 setLargeIcon() .这应该有效。

关于Android通知状态栏和通知正文的不同图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22336456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com