小编Ahm*_*sef的帖子

不能使用黄色与Android牛轧糖通知的小图标

我在Android 7.x中将通知小图标设置为黄色时遇到问题

我正在notification.setColor(Color.YELLOW);构建通知对象时使用.它显示橄榄色(ish)颜色而不是黄色.

也尝试使用,notification.setColor(Color.argb(255,255,255,0));但没有运气,它显示相同的橄榄色(ish)颜色.

这就是它在Android 7.x中的样子

Android 7.1

这就是它在Android 6.x中的样子,这是正确的颜色

Android 6.x

两个图像都使用相同的代码库显示相同的通知,但使用不同的Android设备.

我正在使用PushWoosh发送/接收推送通知,下面是我用来创建通知对象的确切代码.

public class NotificationFactory extends AbsNotificationFactory {
@Override
public Notification onGenerateNotification(PushData pushData) {
    PushwooshUserdata pushwooshUserdata = GsonUtil.fromJson(pushData.getExtras().getString("u"), PushwooshUserdata.class);

    //create notification builder
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext());
    notificationBuilder.setContentTitle("Header");
    notificationBuilder.setContentText("Message");

    //set small icon (usually app icon)
    notificationBuilder.setSmallIcon(R.drawable.notification_icon);
    notificationBuilder.setColor(Color.argb(255,255,255,0));

    //set ticket text
    notificationBuilder.setTicker(getContentFromHtml(pushData.getTicker()));

    //display notification now
    notificationBuilder.setWhen(System.currentTimeMillis());

    //build the notification
    final Notification notification = notificationBuilder.build();

    //add sound
    addSound(notification, pushData.getSound());

    //add vibration
    addVibration(notification, pushData.getVibration());

    //make it cancelable
    addCancel(notification);

    //all done!
    return …
Run Code Online (Sandbox Code Playgroud)

notifications android google-cloud-messaging

5
推荐指数
1
解决办法
747
查看次数