public static void dismissNotification(Context ctx, int groupId) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ctx); notificationManager.cancel(groupId); }
/** * Handles action Dismiss in the provided background thread. */ private void handleActionDismiss() { Log.d(TAG, "handleActionDismiss()"); NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); notificationManagerCompat.cancel(StandaloneMainActivity.NOTIFICATION_ID); }
/** * Handles action Dismiss in the provided background thread. */ private void handleActionDismiss() { Log.d(TAG, "handleActionDismiss()"); NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); notificationManagerCompat.cancel(MainActivity.NOTIFICATION_ID); }
public void cancelNotification(Context context) { boolean updateSummary = false; synchronized (this) { mMessages.clear(); } synchronized (mShowingNotificationLock) { // cancel the notification if (mShowingNotification) { NotificationManagerCompat.from(context).cancel(mNotificationId); mShowingNotification = false; updateSummary = true; } } if (updateSummary) NotificationManager.getInstance().updateSummaryNotification(context, null); }
public void setOpened(Context context, boolean opened) { boolean updateSummary = false; synchronized (this) { mOpened = opened; if (mOpened) { mMessages.clear(); synchronized (mShowingNotificationLock) { // cancel the notification if (mShowingNotification) { NotificationManagerCompat.from(context).cancel(mNotificationId); mShowingNotification = false; updateSummary = true; } } } } if (updateSummary) NotificationManager.getInstance().updateSummaryNotification(context, null); }
/** * 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); } }
/** * 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); } }
@Override public void onMessageSent() { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mContext); notificationManager.cancel(mNotificationId); NotificationManager.getInstance().onNotificationDismissed(mContext, mConnection, mChannel); NotificationManager.getInstance().updateSummaryNotification(mContext, null); }
NotificationManagerCompat.from(context).cancel(CHAT_SUMMARY_NOTIFICATION_ID); return;