2017-08-25 67 views

回答

1

我们将需要更多的细节,如代码或东西,但我认为你需要创建一个带有特定信道ID的通知信道。

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
String id = "my_channel_01"; 
int importance = NotificationManager.IMPORTANCE_LOW; 
NotificationChannel mChannel = new NotificationChannel(id, name,importance); 
mChannel.enableLights(true); 
mNotificationManager.createNotificationChannel(mChannel); 

第一种方法是在构造函数通知中设置通道:

Notification notification = new Notification.Builder(MainActivity.this , id).setContentTitle("Title"); 
mNotificationManager.notify("your_notification_id", notification); 

第二种方法是Notificiation.Builder.setChannelId()

Notification notification = new Notification.Builder(MainActivity.this).setContentTitle("Title"). 
setChannelId(id); 
mNotificationManager.notify("your_notification_id", notification); 

希望这有助于设置通道