Last active
July 5, 2018 03:16
-
-
Save ParkSangGwon/3fd55511de2b9f192ed58a227b08507e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
NotificationChannel notificationChannel = new NotificationChannel("channel_id", "channel_name", NotificationManager.IMPORTANCE_DEFAULT); | |
notificationChannel.setDescription("channel description"); | |
notificationChannel.enableLights(true); | |
notificationChannel.setLightColor(Color.GREEN); | |
notificationChannel.enableVibration(true); | |
notificationChannel.setVibrationPattern(new long[]{100, 200, 100, 200}); | |
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); | |
notificationManager.createNotificationChannel(notificationChannel); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
NotificationChannelGroup group1 = new NotificationChannelGroup("channel_group_id", "channel_group_name"); | |
notificationManager.createNotificationChannelGroup(group1); | |
NotificationChannel notificationChannel = new NotificationChannel("channel_id", "channel_name", NotificationManager.IMPORTANCE_DEFAULT); | |
notificationChannel.setDescription("channel description"); | |
notificationChannel.setGroup("channel_group_id"); | |
notificationChannel.enableLights(true); | |
notificationChannel.setLightColor(Color.GREEN); | |
notificationChannel.enableVibration(true); | |
notificationChannel.setVibrationPattern(new long[]{100, 200, 100, 200}); | |
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); | |
notificationManager.createNotificationChannel(notificationChannel); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment