小编Dem*_*otz的帖子

通知通道 - 设置后是否可以更改 LightColor?

我正在尝试setLightColor使用从 JavaScript 界面返回的颜色进行更改。不幸的是,NotificationCompat.Builder(context, CHANNEL_ID).setLights对 API >= 26 绝对没有影响,所以我不能使用Intent.putExtra或任何类似的东西。

设置好之后还能修改吗?我希望它是动态的。

编辑似乎对我想要的东西有一些误解。我不想碰Broadcast Reciever. 它工作得很好。我想更改通知渠道。它没有更新setLightColor(Color.___)

protected void onCreate

String jobColor = someColor; // Will be filled in by other code - different colour every time
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    CharSequence name = "Channel_Name";
    String description = "Channel_Description";
    int importance = NotificationManager.IMPORTANCE_HIGH;
    NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
    channel.setDescription(description);
    channel.enableLights(true);
    channel.setLightColor(Color.parseColor(jobColor)); // Dynamically set from above
    channel.enableVibration(true);
    NotificationManager notificationManager = …
Run Code Online (Sandbox Code Playgroud)

java notifications android channel led

2
推荐指数
1
解决办法
1984
查看次数

标签 统计

android ×1

channel ×1

java ×1

led ×1

notifications ×1