问题
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