Group ID being ignored when creating NotificationChannel

青春壹個敷衍的年華 提交于 2019-12-11 17:23:04

问题


I'm migrating my apps to Android O (API 26), notification channel group ID always got ignored when creating NotificationChannel:

NotificationManager nm;
nm.createNotificationChannelGroup(new NotificationChannelGroup("test_group", "Test"));
NotificationChannel newCh = new NotificationChannel("test_channel:id123", "Test", NotificationManager.IMPORTANCE_NORMAL);
newCh.setGroup("test_group");
nm.createNotificationChannel(newCh);

NotificationChannel ch = nm.getNotificationChannel("test_channel:id123"); // ch.getGroup() is null

回答1:


You can't use colon ":" in channel ID, change ":" to other characters like underscore "_" will work.



来源:https://stackoverflow.com/questions/45886170/group-id-being-ignored-when-creating-notificationchannel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!