2 回答

TA貢獻1805條經驗 獲得超10個贊
您無法在不刪除頻道的情況下以編程方式更改頻道顏色通知、重要性等。
因為用戶可能已經手動更改了燈光顏色。
以編程方式實現這一點,以獲取頻道并創建一個具有新 ID 的新頻道。刪除舊頻道。如果使用以前的 id 創建頻道,您的更改將不會反映
供參考檢查WhatsApp應用程序嘗試從應用程序更改鈴聲并在左下角的頻道中查看x頻道已刪除消息

TA貢獻1842條經驗 獲得超21個贊
從 createNotificationChannel() 描述:
這也可用于恢復已刪除的頻道并更新現有頻道的 * 名稱、描述、組和/或重要性。
所以你可以試試這個:
NotificationManager notificationManager = getSystemService(NotificationManager.class);
//find created channel
NotificationChannel channel = notificationManager.getNotificationChannel("id");
if (channel != null){
//set new color
channel.setLightColor(0);
//update channel
notificationManager.createNotificationChannel(channel);
}
添加回答
舉報