下面列出了android.app.NotificationChannel#setShowBadge ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@RequiresApi(api = Build.VERSION_CODES.O)
private synchronized void createNotificationChannel() {
CharSequence name = MobiComKitConstants.PUSH_NOTIFICATION_NAME;
int importance = NotificationManager.IMPORTANCE_HIGH;
if (mNotificationManager != null && mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION) == null) {
NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION, name, importance);
mChannel.enableLights(true);
mChannel.setLightColor(Color.GREEN);
mChannel.setShowBadge(ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled());
if (ApplozicClient.getInstance(context).getVibrationOnNotification()) {
mChannel.enableVibration(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
}
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION).build();
mChannel.setSound(TextUtils.isEmpty(soundFilePath) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) : Uri.parse(soundFilePath), audioAttributes);
mNotificationManager.createNotificationChannel(mChannel);
Utils.printLog(context, TAG, "Created notification channel");
}
}
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel()
{
NotificationManager mNotificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
// The id of the channel.
// The user-visible name of the channel.
CharSequence name = "Media playback";
// The user-visible description of the channel.
String description = "Media playback controls";
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
// Configure the notification channel.
mChannel.setDescription(description);
mChannel.setShowBadge(false);
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(mChannel);
}
private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.channel_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
channel.setSound(null, null);
channel.setShowBadge(false);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
}
/**
* for API 26+ create notification channels
*/
private void createchannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel mChannel = new NotificationChannel(id,
getString(R.string.channel_name), //name of the channel
NotificationManager.IMPORTANCE_DEFAULT); //importance level
//important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low?
// Configure the notification channel.
mChannel.setDescription(getString(R.string.channel_description));
mChannel.enableLights(true);
//Sets the notification light color for notifications posted to this channel, if the device supports this feature.
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setShowBadge(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
nm.createNotificationChannel(mChannel);
}
}
/**
* Init notification channels for android 8.0 and higher
*/
private String createNotificationChannel(Context context) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance);
channel.setDescription(CHANNEL_DESCRIPTION);
channel.enableLights(true);
channel.setLightColor(Color.RED);
channel.setShowBadge(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
return CHANNEL_ID;
}
@RequiresApi(api = Build.VERSION_CODES.O)
private synchronized void createSilentNotificationChannel() {
CharSequence name = MobiComKitConstants.SILENT_PUSH_NOTIFICATION;
int importance = NotificationManager.IMPORTANCE_LOW;
if (mNotificationManager != null && mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_SILENT_NOTIFICATION) == null) {
NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_SILENT_NOTIFICATION, name, importance);
mChannel.enableLights(true);
mChannel.setLightColor(Color.GREEN);
if (ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled()) {
mChannel.setShowBadge(true);
} else {
mChannel.setShowBadge(false);
}
mNotificationManager.createNotificationChannel(mChannel);
Utils.printLog(context, TAG, "Created silent notification channel");
}
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
return;
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL,
mContext.getString(R.string.notification_channel_dcc),
NotificationManager.IMPORTANCE_DEFAULT);
channel.setShowBadge(false);
mNotificationManager.createNotificationChannel(channel);
}
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel(ReactApplicationContext context) {
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, "Media playback", NotificationManager.IMPORTANCE_LOW);
mChannel.setDescription("Media playback controls");
mChannel.setShowBadge(false);
mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(mChannel);
}
/**
* Create notification channel for Android O
*/
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
final CharSequence name = getString(R.string.channel_name);
final int importance = NotificationManager.IMPORTANCE_LOW;
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setShowBadge(false);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
channel.enableVibration(false);
channel.enableLights(false);
channel.setBypassDnd(false);
final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.createNotificationChannel(channel);
}
private static void createForegroundNotificationChannel(Context context) {
if (!createdForegroundChannel && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = context.getString(R.string.app_name);
int importance = NotificationManager.IMPORTANCE_MIN;
NotificationChannel channel = new NotificationChannel(FOREGROUND_CHANNEL_ID, name, importance);
channel.setSound(null, null);
channel.setShowBadge(false);
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
createdForegroundChannel = true;
}
}
}
@Override
public void onCreate() {
super.onCreate();
//This ensures the singleton is created with the correct context, which needs to be the
//application context
DaoStore.getInstance(this.getApplicationContext());
LayerHelper.getInstance(this.getApplicationContext());
StaticFeatureHelper.getInstance(this.getApplicationContext());
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
HttpClientManager.initialize(this);
// setup the screen unlock stuff
registerReceiver(ScreenChangeReceiver.getInstance(), new IntentFilter(Intent.ACTION_SCREEN_ON));
registerActivityLifecycleCallbacks(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
int dayNightTheme = preferences.getInt(getResources().getString(R.string.dayNightThemeKey), getResources().getInteger(R.integer.dayNightThemeDefaultValue));
AppCompatDelegate.setDefaultNightMode(dayNightTheme);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(MAGE_NOTIFICATION_CHANNEL_ID,"MAGE", NotificationManager.IMPORTANCE_LOW);
channel.setShowBadge(true);
notificationManager.createNotificationChannel(channel);
NotificationChannel observationChannel = new NotificationChannel(MAGE_OBSERVATION_NOTIFICATION_CHANNEL_ID,"MAGE Observations", NotificationManager.IMPORTANCE_HIGH);
observationChannel.setShowBadge(true);
notificationManager.createNotificationChannel(observationChannel);
}
}
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DfuServiceInitiator.createDfuNotificationChannel(this);
final NotificationChannel channel = new NotificationChannel(CONNECTED_DEVICE_CHANNEL, getString(R.string.channel_connected_devices_title), NotificationManager.IMPORTANCE_LOW);
channel.setDescription(getString(R.string.channel_connected_devices_description));
channel.setShowBadge(false);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
final NotificationChannel fileChannel = new NotificationChannel(FILE_SAVED_CHANNEL, getString(R.string.channel_files_title), NotificationManager.IMPORTANCE_LOW);
fileChannel.setDescription(getString(R.string.channel_files_description));
fileChannel.setShowBadge(false);
fileChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
final NotificationChannel proximityChannel = new NotificationChannel(PROXIMITY_WARNINGS_CHANNEL, getString(R.string.channel_proximity_warnings_title), NotificationManager.IMPORTANCE_LOW);
proximityChannel.setDescription(getString(R.string.channel_proximity_warnings_description));
proximityChannel.setShowBadge(false);
proximityChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
notificationManager.createNotificationChannel(fileChannel);
notificationManager.createNotificationChannel(proximityChannel);
}
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "Name";
String description = "Description";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
channel.setDescription(description);
channel.setShowBadge(false);
NotificationManager notificationManager = getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
}
@TargetApi(26)
private void createNotificationChannel() {
NotificationChannel channel = new NotificationChannel("ongoing",
getString(R.string.notificationChannelName), NotificationManager.IMPORTANCE_LOW);
channel.setShowBadge(false);
channel.setSound(null, null);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (notificationManager != null)
notificationManager.createNotificationChannel(channel);
}
@RequiresApi(api = Build.VERSION_CODES.O)
NotificationChannel getLocationNotificationChannel(Context context) {
NotificationChannel channel = new NotificationChannel(
GeometricWeather.NOTIFICATION_CHANNEL_ID_LOCATION,
GeometricWeather.getNotificationChannelName(
context, GeometricWeather.NOTIFICATION_CHANNEL_ID_LOCATION),
NotificationManager.IMPORTANCE_MIN);
channel.setShowBadge(false);
channel.setLightColor(ContextCompat.getColor(context, R.color.colorPrimary));
return channel;
}
public void createChannels(){
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel mChannelOne = new NotificationChannel(CHANNEL_GENERAL_ID, CHANNEL_GENERAL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
mChannelOne.setDescription(CHANNEL_GENERAL_ABOUT);
mChannelOne.enableLights(false);
mChannelOne.setLightColor(getColor(R.color.colorPrimary));
mChannelOne.setShowBadge(true);
mChannelOne.enableVibration(false);
mChannelOne.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getNotificationManager().createNotificationChannel(mChannelOne);
NotificationChannel mChannelTwo = new NotificationChannel(CHANNEL_BUG_TRACKER_ID, CHANNEL_BUG_TRACKER_NAME, NotificationManager.IMPORTANCE_HIGH);
mChannelTwo.setDescription(CHANNEL_BUG_TRACKER_ABOUT);
mChannelTwo.enableLights(true);
mChannelTwo.enableVibration(true);
mChannelTwo.setLightColor(getColor(R.color.colorPrimary));
mChannelTwo.setShowBadge(true);
getNotificationManager().createNotificationChannel(mChannelTwo);
NotificationChannel mChannelThree = new NotificationChannel(CHANNEL_SERVICE_ID, CHANNEL_SERVICE_NAME, NotificationManager.IMPORTANCE_DEFAULT);
mChannelThree.setDescription(CHANNEL_SERVICE_ABOUT);
mChannelThree.enableLights(false);
mChannelThree.enableVibration(false);
mChannelThree.setLightColor(getColor(R.color.colorPrimary));
mChannelThree.setShowBadge(true);
mChannelThree.setSound(null, null);
getNotificationManager().createNotificationChannel(mChannelThree);
}
}
/**
* Creates Notification Channel. This is required in Android O+ to display notifications.
*/
@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
if (mNotificationManager.getNotificationChannel(CHANNEL_ID) == null) {
NotificationChannel notificationChannel =
new NotificationChannel(CHANNEL_ID, "Bop",
android.app.NotificationManager.IMPORTANCE_LOW);
notificationChannel.setDescription("Music player");
notificationChannel.setShowBadge(false);
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(notificationChannel);
}
}
public static Notification makeNotification(Context context, String artist, String track, long duration, boolean retentionNotif, boolean isPlaying) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
boolean prefOverlay = sharedPref.getBoolean("pref_overlay", false) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(context));
int notificationPref = prefOverlay ? 2 : Integer.valueOf(sharedPref.getString("pref_notifications", "0"));
Intent activityIntent = new Intent(context.getApplicationContext(), MainActivity.class)
.setAction("com.geecko.QuickLyric.getLyrics")
.putExtra("retentionNotif", retentionNotif)
.putExtra("TAGS", new String[]{artist, track});
Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE")
.putExtra("artist", artist).putExtra("track", track).putExtra("duration", duration);
final Intent overlayIntent = new Intent(context.getApplicationContext(), LyricsOverlayService.class)
.setAction(LyricsOverlayService.CLICKED_FLOATING_ACTION);
PendingIntent overlayPending = PendingIntent.getService(context.getApplicationContext(), 0, overlayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent openAppPending = PendingIntent.getActivity(context.getApplicationContext(), 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent wearablePending = PendingIntent.getBroadcast(context.getApplicationContext(), 8, wearableIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Action wearableAction =
new NotificationCompat.Action.Builder(R.drawable.ic_watch,
context.getString(R.string.wearable_prompt), wearablePending)
.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(notificationPref == 1 && isPlaying ? TRACK_NOTIF_CHANNEL : TRACK_NOTIF_HIDDEN_CHANNEL,
context.getString(R.string.pref_notifications),
notificationPref == 1 && isPlaying ? NotificationManager.IMPORTANCE_LOW : NotificationManager.IMPORTANCE_MIN);
notificationChannel.setShowBadge(false);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
}
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context.getApplicationContext(), notificationPref == 1 && isPlaying ? TRACK_NOTIF_CHANNEL : TRACK_NOTIF_HIDDEN_CHANNEL);
NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context.getApplicationContext(), TRACK_NOTIF_HIDDEN_CHANNEL);
int[] themes = new int[]{R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo,
R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime,
R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark};
int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));
context.setTheme(themes[themeNum]);
notifBuilder.setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_notif : R.drawable.ic_notif4)
.setContentTitle(context.getString(R.string.app_name))
.setContentText(String.format("%s - %s", artist, track))
.setContentIntent(prefOverlay ? overlayPending : openAppPending)
.setVisibility(-1) // Notification.VISIBILITY_SECRET
.setGroup("Lyrics_Notification")
.setColor(ColorUtils.getPrimaryColor(context))
.setShowWhen(false)
.setGroupSummary(true);
wearableNotifBuilder.setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_notif : R.drawable.ic_notif4)
.setContentTitle(context.getString(R.string.app_name))
.setContentText(String.format("%s - %s", artist, track))
.setContentIntent(openAppPending)
.setVisibility(-1) // Notification.VISIBILITY_SECRET
.setGroup("Lyrics_Notification")
.setOngoing(false)
.setColor(ColorUtils.getPrimaryColor(context))
.setGroupSummary(false)
.setShowWhen(false)
.extend(new NotificationCompat.WearableExtender().addAction(wearableAction));
if (notificationPref == 2) {
notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN
wearableNotifBuilder.setPriority(-2);
} else
notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW
Notification notif = notifBuilder.build();
Notification wearableNotif = wearableNotifBuilder.build();
if (notificationPref == 2 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
if (notificationPref == 1)
notif.flags |= Notification.FLAG_AUTO_CANCEL;
try {
context.getPackageManager().getPackageInfo("com.google.android.wearable.app", PackageManager.GET_META_DATA);
NotificationManagerCompat.from(context).notify(8, wearableNotif); // TODO Make Android Wear app
} catch (PackageManager.NameNotFoundException ignored) {
}
return notif;
}
public static void sendNotification(Context context,
String[] permissions,
int requestCode,
String notificationTitle,
String notificationText,
int notificationIcon,
ResultReceiver receiver) {
Intent intent = new Intent(context, PermissionActivity.class);
intent.putExtra(Const.REQUEST_CODE, requestCode);
intent.putExtra(Const.PERMISSIONS_ARRAY, permissions);
intent.putExtra(Const.RESULT_RECEIVER, receiver);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
}
PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_CODE_PUSH, intent,
PendingIntent.FLAG_ONE_SHOT);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.channel_name), NotificationManager.IMPORTANCE_HIGH);
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setShowBadge(true);
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(notificationChannel);
}
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(notificationIcon)
.setContentTitle(notificationTitle)
.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText))
.setContentText(notificationText)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVibrate(new long[0])
.setContentIntent(pendingIntent);
notificationManager.notify(requestCode, notificationBuilder.build());
}
@RequiresApi(Build.VERSION_CODES.O)
public static void createChannels(NotificationManager notificationManager) {
try {
// Low importance so that persistent notification can be sorted towards bottom of
// notification shade. Also prevents vibrations caused by persistent notification
NotificationChannel foreground =
new NotificationChannel(
Channel.FOREGROUND,
"Gotify foreground notification",
NotificationManager.IMPORTANCE_LOW);
foreground.setShowBadge(false);
NotificationChannel messagesImportanceMin =
new NotificationChannel(
Channel.MESSAGES_IMPORTANCE_MIN,
"Min priority messages (<1)",
NotificationManager.IMPORTANCE_MIN);
NotificationChannel messagesImportanceLow =
new NotificationChannel(
Channel.MESSAGES_IMPORTANCE_LOW,
"Low priority messages (1-3)",
NotificationManager.IMPORTANCE_LOW);
NotificationChannel messagesImportanceDefault =
new NotificationChannel(
Channel.MESSAGES_IMPORTANCE_DEFAULT,
"Normal priority messages (4-7)",
NotificationManager.IMPORTANCE_DEFAULT);
messagesImportanceDefault.enableLights(true);
messagesImportanceDefault.setLightColor(Color.CYAN);
messagesImportanceDefault.enableVibration(true);
NotificationChannel messagesImportanceHigh =
new NotificationChannel(
Channel.MESSAGES_IMPORTANCE_HIGH,
"High priority messages (>7)",
NotificationManager.IMPORTANCE_HIGH);
messagesImportanceHigh.enableLights(true);
messagesImportanceHigh.setLightColor(Color.CYAN);
messagesImportanceHigh.enableVibration(true);
notificationManager.createNotificationChannel(foreground);
notificationManager.createNotificationChannel(messagesImportanceMin);
notificationManager.createNotificationChannel(messagesImportanceLow);
notificationManager.createNotificationChannel(messagesImportanceDefault);
notificationManager.createNotificationChannel(messagesImportanceHigh);
} catch (Exception e) {
Log.e("Could not create channel", e);
}
}