Java Code Examples for android.app.Notification#getChannelId()
The following examples show how to use
android.app.Notification#getChannelId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Collect all {@link Uri} that should have permission granted to whoever * will be rendering it. */ protected void calculateGrantableUris() { final Notification notification = getNotification(); notification.visitUris((uri) -> { visitGrantableUri(uri, false); }); if (notification.getChannelId() != null) { NotificationChannel channel = getChannel(); if (channel != null) { visitGrantableUri(channel.getSound(), (channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) != 0); } } }
Example 2
Source File: NotificationChannels.java From xDrip with GNU General Public License v3.0 | 4 votes |
@TargetApi(26) public static NotificationChannel getChan(NotificationCompat.Builder wip) { final Notification temp = wip.build(); if (temp.getChannelId() == null) return null; // create generic audio attributes final AudioAttributes generic_audio = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) .build(); // create notification channel for hashing purposes from the existing notification builder NotificationChannel template = new NotificationChannel( temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT); // mirror the notification parameters in the channel template.setGroup(temp.getChannelId()); template.setVibrationPattern(wip.mNotification.vibrate); template.setSound(wip.mNotification.sound, generic_audio); template.setLightColor(wip.mNotification.ledARGB); if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // get a nice string to identify the hash final String mhash = my_text_hash(template); // create another notification channel using the hash because id is immutable final NotificationChannel channel = new NotificationChannel( template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT); // mirror the settings from the previous channel channel.setSound(template.getSound(), generic_audio); if (addChannelGroup()) { channel.setGroup(template.getGroup()); } else { channel.setGroup(channel.getId()); } channel.setDescription(template.getDescription()); channel.setVibrationPattern(template.getVibrationPattern()); template.setLightColor(wip.mNotification.ledARGB); if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // create a group to hold this channel if one doesn't exist or update text getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup()))); // create this channel if it doesn't exist or update text getNotifManager().createNotificationChannel(channel); return channel; }
Example 3
Source File: NotificationChannels.java From xDrip with GNU General Public License v3.0 | 4 votes |
@TargetApi(26) public static NotificationChannel getChan(Notification.Builder wip) { final Notification temp = wip.build(); if (temp.getChannelId() == null) return null; // create generic audio attributes final AudioAttributes generic_audio = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) .build(); // create notification channel for hashing purposes from the existing notification builder NotificationChannel template = new NotificationChannel( temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT); // mirror the notification parameters in the channel template.setGroup(temp.getChannelId()); template.setVibrationPattern(temp.vibrate); template.setSound(temp.sound, generic_audio); template.setLightColor(temp.ledARGB); if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // get a nice string to identify the hash final String mhash = my_text_hash(template); // create another notification channel using the hash because id is immutable final NotificationChannel channel = new NotificationChannel( template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT); // mirror the settings from the previous channel channel.setSound(template.getSound(), generic_audio); if (addChannelGroup()) { channel.setGroup(template.getGroup()); } else { channel.setGroup(channel.getId()); } channel.setDescription(template.getDescription()); channel.setVibrationPattern(template.getVibrationPattern()); template.setLightColor(temp.ledARGB); if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // create a group to hold this channel if one doesn't exist or update text getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup()))); // create this channel if it doesn't exist or update text getNotifManager().createNotificationChannel(channel); return channel; }
Example 4
Source File: NotificationChannels.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@TargetApi(26) public static NotificationChannel getChan(NotificationCompat.Builder wip) { final Notification temp = wip.build(); if (temp.getChannelId() == null) return null; // create generic audio attributes final AudioAttributes generic_audio = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) .build(); // create notification channel for hashing purposes from the existing notification builder NotificationChannel template = new NotificationChannel( temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT); // mirror the notification parameters in the channel template.setGroup(temp.getChannelId()); template.setVibrationPattern(wip.mNotification.vibrate); template.setSound(wip.mNotification.sound, generic_audio); template.setLightColor(wip.mNotification.ledARGB); if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // get a nice string to identify the hash final String mhash = my_text_hash(template); // create another notification channel using the hash because id is immutable final NotificationChannel channel = new NotificationChannel( template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT); // mirror the settings from the previous channel channel.setSound(template.getSound(), generic_audio); if (addChannelGroup()) { channel.setGroup(template.getGroup()); } else { channel.setGroup(channel.getId()); } channel.setDescription(template.getDescription()); channel.setVibrationPattern(template.getVibrationPattern()); template.setLightColor(wip.mNotification.ledARGB); if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // create a group to hold this channel if one doesn't exist or update text getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup()))); // create this channel if it doesn't exist or update text getNotifManager().createNotificationChannel(channel); return channel; }
Example 5
Source File: NotificationChannels.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@TargetApi(26) public static NotificationChannel getChan(Notification.Builder wip) { final Notification temp = wip.build(); if (temp.getChannelId() == null) return null; // create generic audio attributes final AudioAttributes generic_audio = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) .build(); // create notification channel for hashing purposes from the existing notification builder NotificationChannel template = new NotificationChannel( temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT); // mirror the notification parameters in the channel template.setGroup(temp.getChannelId()); template.setVibrationPattern(temp.vibrate); template.setSound(temp.sound, generic_audio); template.setLightColor(temp.ledARGB); if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // get a nice string to identify the hash final String mhash = my_text_hash(template); // create another notification channel using the hash because id is immutable final NotificationChannel channel = new NotificationChannel( template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT); // mirror the settings from the previous channel channel.setSound(template.getSound(), generic_audio); if (addChannelGroup()) { channel.setGroup(template.getGroup()); } else { channel.setGroup(channel.getId()); } channel.setDescription(template.getDescription()); channel.setVibrationPattern(template.getVibrationPattern()); template.setLightColor(temp.ledARGB); if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0)) template.enableLights(true); // weird how this doesn't work like vibration pattern template.setDescription(temp.getChannelId() + " " + wip.hashCode()); // create a group to hold this channel if one doesn't exist or update text getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup()))); // create this channel if it doesn't exist or update text getNotifManager().createNotificationChannel(channel); return channel; }