Skip to content

Instantly share code, notes, and snippets.

@nazmulidris
Last active August 11, 2017 22:03
Show Gist options
  • Save nazmulidris/2404a2f2108f4cdbfa81d84aa6799257 to your computer and use it in GitHub Desktop.
Save nazmulidris/2404a2f2108f4cdbfa81d84aa6799257 to your computer and use it in GitHub Desktop.
private static final String CHANNEL_ID = "media_playback_channel";
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
NotificationManager
mNotificationManager =
(NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
// The id of the channel.
String id = CHANNEL_ID;
// 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(id, name, importance);
// Configure the notification channel.
mChannel.setDescription(description);
mChannel.setShowBadge(false);
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(mChannel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment