【发布时间】:2018-06-22 07:10:43
【问题描述】:
我正在制作一个应用程序,它会在完成特定任务时显示通知。这是我的代码:
int NOTIFICATION_ID = 4024;
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setContentTitle("Title")
.setContentText("Text")
.setSmallIcon(R.drawable.ic_notification)
.setLights(Color.GREEN, 1000, 1000)
.setVibrate(new long[] {500, 500, 500, 500, 500})
.setAutoCancel(true);
Intent resultIntent = new Intent(this, MainActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0,
resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
这是我的图标(来自https://material.io/icons/#ic_signal_cellular_4_bar):
运行时,图标显示正常,但不会根据状态栏的背景改变颜色,例如 whatsapp 的图标会:
所以我的问题是如何让它根据背景改变颜色。
编辑:
此外,当使用白色图标时,它不会改变颜色。
【问题讨论】:
标签: java android notifications