You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android推送通知图标背景色不一致,如何统一为固定颜色?

问题:FCM推送通知图标背景色在三星平板前台/后台不一致

在三星平板上使用Firebase Cloud Messaging(FCM)发送推送通知时,发现应用前台与后台状态下,通知图标的背景色存在明显差异,已在通知面板中确认该问题。

进一步测试发现:应用前台接收推送时,通知图标的背景色会跟随应用图标的颜色变化——修改应用图标后,前台推送通知图标的背景色也同步改变。

尝试通过代码调用SetColor方法强制设置背景色,但两种写法均未生效:

  • 自定义ARGB颜色写法:
int color = Color.Argb(255, 255, 123, 0);
.SetColor(color)
  • 系统预设颜色写法:
.SetColor(Color.Orange)

完整的前台通知构建代码如下:

var pendingIntent = PendingIntent.GetActivity(this, Activity1.NOTIFICATION_ID, intent, PendingIntentFlags.Immutable);

var notificationBuilder = new NotificationCompat.Builder(this, Activity1.CHANNEL_ID)
                                .SetSmallIcon(Resource.Mipmap.ic_stat_name)
                                .SetColor(Color.Orange)
                                .SetContentTitle(Title)
                                .SetContentText(messageBody)
                                .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                .SetVibrate(new long[] { 1000, 1000, 0, 0, 0 })
                                .SetLights(Android.Graphics.Color.Red, 3000, 3000)
                                .SetPriority((int)NotificationPriority.High)
                                .SetAutoCancel(true)
                                .SetContentIntent(pendingIntent);

var notificationManager = NotificationManagerCompat.From(this);
notificationManager.Notify(Activity1.NOTIFICATION_ID, notificationBuilder.Build());

请问如何实现通知图标始终使用相同的背景色?


内容的提问来源于stack exchange,提问作者John_Kub

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 00:07:24