我正在创建一个应用,它会在某个任务完成时显示通知。这是我的代码:
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的图标会显示:
所以我的问题是我如何根据背景改变颜色。
编辑:
使用白色图标时,它也不会改变颜色。
答案 0 :(得分:0)