//创建通道
public static void createNotifyChannel(Context context, String channelId) {
//创建一个默认的重要性的通知渠道
//参数为通道ID,通道名,通道重要性
NotificationChannel channel = new NotificationChannel(channelId, "Channel", NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(null, null); //设置通道推送的铃声,null表示静音
channel.enableLights(true); //设置桌面角标
channel.setLightColor(Color.RED); //角标颜色
channel.setShowBadge(true); //长按妆面图标时显示该渠道明细
//从系统管理器中获取通知管理器
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
}