.setAutoCancel(true) .build(); notificationManager.notify((int) deckId, notification);
/** * 通知発行用のヘルパークラス * @param context * @param tag * @param notificationId * @param notification */ private static void notify(@NonNull final Context context, @Nullable final String tag, final int notificationId, @NonNull final Notification notification) { NotificationManagerCompat.from(context) .notify(tag, notificationId, notification); }
private static void publishNotification(Context ctx, Notification notification, int groupId) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ctx); notificationManager.notify(groupId, notification); }
/** * Handles action Snooze in the provided background thread. */ private void handleActionSnooze() { Log.d(TAG, "handleActionSnooze()"); // You could use NotificationManager.getActiveNotifications() if you are targeting SDK 23 // and above, but we are targeting devices with lower SDK API numbers, so we saved the // builder globally and get the notification back to recreate it later. NotificationCompat.Builder notificationCompatBuilder = GlobalNotificationBuilder.getNotificationCompatBuilderInstance(); // Recreate builder from persistent state if app process is killed if (notificationCompatBuilder == null) { // Note: New builder set globally in the method notificationCompatBuilder = recreateBuilderWithBigTextStyle(); } Notification notification; notification = notificationCompatBuilder.build(); if (notification != null) { NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); notificationManagerCompat.cancel(StandaloneMainActivity.NOTIFICATION_ID); try { Thread.sleep(SNOOZE_TIME); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } notificationManagerCompat.notify(StandaloneMainActivity.NOTIFICATION_ID, notification); } }
/** * Handles action Snooze in the provided background thread. */ private void handleActionSnooze() { Log.d(TAG, "handleActionSnooze()"); // You could use NotificationManager.getActiveNotifications() if you are targeting SDK 23 // and above, but we are targeting devices with lower SDK API numbers, so we saved the // builder globally and get the notification back to recreate it later. NotificationCompat.Builder notificationCompatBuilder = GlobalNotificationBuilder.getNotificationCompatBuilderInstance(); // Recreate builder from persistent state if app process is killed if (notificationCompatBuilder == null) { // Note: New builder set globally in the method notificationCompatBuilder = recreateBuilderWithBigTextStyle(); } Notification notification; notification = notificationCompatBuilder.build(); if (notification != null) { NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); notificationManagerCompat.cancel(MainActivity.NOTIFICATION_ID); try { Thread.sleep(SNOOZE_TIME); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } notificationManagerCompat.notify(MainActivity.NOTIFICATION_ID, notification); } }
notificationManagerCompat.notify(MainActivity.NOTIFICATION_ID, updatedNotification);
notificationManagerCompat.notify( StandaloneMainActivity.NOTIFICATION_ID, updatedNotification);
notificationManagerCompat.notify(StandaloneMainActivity.NOTIFICATION_ID, notification);
notificationManagerCompat.notify(MainActivity.NOTIFICATION_ID, notification);
.setContentIntent(intent); NotificationManagerCompat.from(context).notify(CHAT_SUMMARY_NOTIFICATION_ID, notification.build());
NotificationManagerCompat.from(context).notify(mNotificationId, notification.build()); mShowingNotification = true;
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
Event event = AppDatabase.getInstance(this).getScheduleDao().getEvent(eventId); if (event != null) { NotificationManagerCompat.from(this).notify((int) eventId, buildNotification(event));
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);
mNotificationManagerCompat.notify(NOTIFICATION_ID, notification);