List of usage examples for android.service.notification StatusBarNotification getTag
public String getTag()
From source file:com.cyanogenmod.messaging.quickmessage.QuickMessagePopup.java
/** * Clears the status bar notification and, optionally, mark all messages as read * This is used to clean up when we are done with all qm's * * @param markAsRead - should remaining qm's be maked as read? *//*from ww w . j av a2s . com*/ private void clearNotification(boolean markAsRead) { // Dismiss the notification that brought us here. NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); StatusBarNotification[] statusBarNotifications = notificationManager.getActiveNotifications(); final String packageName = getPackageName(); for (StatusBarNotification statusBarNotification : statusBarNotifications) { if (packageName.equals(statusBarNotification.getPackageName())) { notificationManager.cancel(statusBarNotification.getTag(), statusBarNotification.getId()); break; } } // Mark all contained conversations as seen if (markAsRead) { markAllMessagesRead(); } // Clear the messages list mMessageList.clear(); if (DEBUG) Log.d(LOG_TAG, "clearNotification(): Message list cleared. Size = " + mMessageList.size()); }
From source file:com.achep.acdisplay.notifications.OpenNotification.java
/** * Note, that method is not equals with {@link #equals(Object)} method. * * @param n notification to compare with. * @return {@code true} if notifications are from the same source and will * be handled by system as same notifications, {@code false} otherwise. *//*from w ww . jav a2 s . c o m*/ @SuppressLint("NewApi") @SuppressWarnings("ConstantConditions") public boolean hasIdenticalIds(@Nullable OpenNotification n) { if (n == null) return false; StatusBarNotification sbn = getStatusBarNotification(); StatusBarNotification sbn2 = n.getStatusBarNotification(); if (Device.hasLemonCakeApi()) { // FIXME: Android L reflections. // service.cancelNotification(notification.getKey()); try { Method method = sbn.getClass().getMethod("getKey"); method.setAccessible(true); String key = (String) method.invoke(sbn); String key2 = (String) method.invoke(sbn2); return new EqualsBuilder().append(key, key2).isEquals(); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { /* sad, but true */ } } return new EqualsBuilder().append(sbn.getId(), sbn2.getId()).append(getPackageName(), n.getPackageName()) .append(sbn.getTag(), sbn2.getTag()).isEquals(); }