// notificationChannel.enableVibration(true);//是否允许震动
// notificationChannel.setVibrationPattern(new long[]{100, 100, 200});//设置震动模式
// notificationChannel.getAudioAttributes();//获取系统响铃配置
// notificationChannel.getGroup();//获取消息渠道组
// notificationChannel.setBypassDnd(true);
// notificationChannel.setDescription(“description”);
// notificationChannel.setLightColor(Color.GREEN);//制定闪灯是灯光颜色
// notificationChannel.setShowBadge(true);
// getNotificationManager().createNotificationChannel(notificationChannel);
//第一个参数:channel_id
//第二个参数:channel_name
//第三个参数:设置通知重要性级别
//注意:该级别必须要在 NotificationChannel 的构造函数中指定,总共要五个级别;
//范围是从 NotificationManager.IMPORTANCE_NONE(0) ~ NotificationManager.IMPORTANCE_HIGH(4)
NotificationChannel channel = new NotificationChannel(id, name,
NotificationManager.IMPORTANCE_DEFAULT);
// channel.canBypassDnd();//是否绕过请勿打扰模式
channel.enableLights(true);//闪光灯
channel.setLockscreenVisibility(VISIBILITY_SECRET);//锁屏显示通知
channel.setLightColor(Color.RED);//闪关灯的灯光颜色
channel.canShowBadge();//桌面launcher的消息角标
channel.enableVibration(true);//是否允许震动
channel.getAudioAttributes();//获取系统通知响铃声音的配置
channel.getGroup();//获取通知取到组
channel.setBypassDnd(true);//设置可绕过 请勿打扰模式
channel.setVibrationPattern(new long[]{100, 100, 200});//设置震动模式
channel.shouldShowLights();//是否会有灯光
getNotificationManager().createNotificationChannel(channel);
}
}
/**
-
获取通知管理者对象
-
@return
*/
public NotificationManager getNotificationManager() {
if (notificationManager == null) {
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
return notificationManager;
}
/**
- 对应Android8.0生成notification的方法,通过此方法获取notification
*/
public Notification.Builder getChannelNotification(int iconRes, Str