Skip to content

Instantly share code, notes, and snippets.

View AliAsadi's full-sized avatar
:octocat:

Ali Asadi AliAsadi

:octocat:
View GitHub Profile
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Default", NotificationManager.IMPORTANCE_DEFAULT);
channel.setVibrationPattern(new long[0]);
channel.enableVibration(false);
channel.setSound(null,null);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
new Notification.Builder(context)
.setContentTitle(title)
.setContentText(contentText)
.setSmallIcon(R.drawable.icon)
.setContentIntent(intent);