List of usage examples for android.app NotificationChannel setBypassDnd
public void setBypassDnd(boolean bypassDnd)
From source file:com.none.tom.simplerssreader.service.FeedUpdateBackgroundService.java
@SuppressWarnings({ "ConstantConditions", "deprecation" }) private static void showNotification(final Context context, final List<String> payload) { final NotificationManager manager = context.getSystemService(NotificationManager.class); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { final NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channel.setBypassDnd(false); channel.enableLights(true);/*from www. ja v a 2 s . co m*/ channel.setShowBadge(true); channel.enableVibration(true); manager.createNotificationChannel(channel); } final PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle() .setBigContentTitle(context.getString(R.string.notification_title_big)); final int size = payload.size(); for (int i = 0; i < size; i++) { style.addLine(payload.get(i)); } manager.notify(ID_NOTIFICATION, new NotificationCompat.Builder(context) .setChannelId(NOTIFICATION_CHANNEL_ID).setSmallIcon(R.drawable.ic_rss_feed_white_24dp) .setContentTitle(context.getString(R.string.notification_title)) .setContentText(context.getString(R.string.notification_text)).setContentIntent(intent) .setStyle(style).setWhen(System.currentTimeMillis()).setAutoCancel(true).setShowWhen(true).build()); }