List of usage examples for android.app Notification getGroup
public String getGroup()
From source file:com.androidinspain.deskclock.alarms.AlarmNotifications.java
@TargetApi(Build.VERSION_CODES.N) private static Notification getActiveGroupSummaryNotification(Context context, String group) { final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final StatusBarNotification[] notifications = nm.getActiveNotifications(); for (StatusBarNotification statusBarNotification : notifications) { final Notification n = statusBarNotification.getNotification(); if (isGroupSummary(n) && group.equals(n.getGroup())) { return n; }// w ww. ja v a 2 s . co m } return null; }
From source file:com.stasbar.knowyourself.alarms.AlarmNotifications.java
@TargetApi(Build.VERSION_CODES.N) private static int getActiveNotificationsCount(Context context, String group) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); StatusBarNotification[] notifications = nm.getActiveNotifications(); int count = 0; for (StatusBarNotification statusBarNotification : notifications) { final Notification n = statusBarNotification.getNotification(); if ((n.flags & Notification.FLAG_GROUP_SUMMARY) != Notification.FLAG_GROUP_SUMMARY && group.equals(n.getGroup())) { count++;//from ww w.j ava2 s .c o m } } return count; }
From source file:com.androidinspain.deskclock.alarms.AlarmNotifications.java
/** * Method which returns the first active notification for a given group. If a notification was * just posted, provide it to make sure it is included as a potential result. If a notification * was just canceled, provide the id so that it is not included as a potential result. These * extra parameters are needed due to a race condition which exists in * {@link NotificationManager#getActiveNotifications()}. * * @param context Context from which to grab the NotificationManager * @param group The group key to query for notifications * @param canceledNotificationId The id of the just-canceled notification (-1 if none) * @param postedNotification The notification that was just posted * @return The first active notification for the group *///w w w .j av a2 s . c o m @TargetApi(Build.VERSION_CODES.N) private static Notification getFirstActiveNotification(Context context, String group, int canceledNotificationId, Notification postedNotification) { final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final StatusBarNotification[] notifications = nm.getActiveNotifications(); Notification firstActiveNotification = postedNotification; for (StatusBarNotification statusBarNotification : notifications) { final Notification n = statusBarNotification.getNotification(); if (!isGroupSummary(n) && group.equals(n.getGroup()) && statusBarNotification.getId() != canceledNotificationId) { if (firstActiveNotification == null || n.getSortKey().compareTo(firstActiveNotification.getSortKey()) < 0) { firstActiveNotification = n; } } } return firstActiveNotification; }
From source file:com.bluelinelabs.logansquare.typeconverters.NotificationConverter.java
@TargetApi(Build.VERSION_CODES.KITKAT) @NonNull/* w w w . ja va2s. c o m*/ public static SimpleNotification toSimpleNotification(@NonNull Notification notification) { SimpleNotification simpleNotification = new SimpleNotification(); simpleNotification.autoCancel = (notification.flags & Notification.FLAG_AUTO_CANCEL) == Notification.FLAG_AUTO_CANCEL; android.util.Log.d("json2notification", "autoCancel:" + simpleNotification.autoCancel); //simpleNotification.bigPictureStyle // TODO simpleNotification.category = notification.category; simpleNotification.color = notification.color > 0 ? notification.color : null; simpleNotification.contentInfo = notification.extras.getString(Notification.EXTRA_INFO_TEXT); simpleNotification.contentIntent = notification.contentIntent; simpleNotification.contentTitle = notification.extras.getString(Notification.EXTRA_TITLE); simpleNotification.contentText = notification.extras.getString(Notification.EXTRA_TEXT); simpleNotification.defaults = notification.defaults > 0 ? notification.defaults : null; simpleNotification.deleteIntent = notification.deleteIntent; //simpleNotification.extras; simpleNotification.groupKey = notification.getGroup(); if (simpleNotification.groupKey != null) { simpleNotification.groupSummary = (notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY; } Bitmap bitmap = notification.extras.getParcelable(Notification.EXTRA_LARGE_ICON); if (bitmap != null) simpleNotification.largeIcon = Bitmaps.base64(bitmap); if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) == Notification.FLAG_SHOW_LIGHTS) { simpleNotification.lights = Arrays.asList(notification.ledARGB, notification.ledOnMS, notification.ledOffMS); } simpleNotification.localOnly = (notification.flags & Notification.FLAG_LOCAL_ONLY) == Notification.FLAG_LOCAL_ONLY; simpleNotification.number = notification.number > 0 ? notification.number : null; simpleNotification.ongoing = (notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT; simpleNotification.onlyAlertOnce = (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == Notification.FLAG_ONLY_ALERT_ONCE; String[] people = notification.extras.getStringArray(Notification.EXTRA_PEOPLE); if (people != null) { simpleNotification.people = Arrays.asList(people); } simpleNotification.priority = notification.priority > 0 ? notification.priority : null; //simpleNotification.progress; simpleNotification.publicVersion = notification.publicVersion; simpleNotification.showWhen = notification.extras.getBoolean(Notification.EXTRA_SHOW_WHEN); if (simpleNotification.showWhen) { simpleNotification.when = notification.when; } simpleNotification.smallIcon = String.valueOf(notification.extras.getInt(Notification.EXTRA_SMALL_ICON)); // TODO getResourceNameById() android.util.Log.d("json2notification", "simpleNotification.smallIcon" + simpleNotification.smallIcon); simpleNotification.sortKey = notification.getSortKey(); simpleNotification.sound = notification.sound; simpleNotification.subText = notification.extras.getString(Notification.EXTRA_SUB_TEXT); simpleNotification.tickerText = notification.tickerText; simpleNotification.usesChronometer = notification.extras.getBoolean(Notification.EXTRA_SHOW_CHRONOMETER); simpleNotification.visibility = notification.visibility > 0 ? notification.visibility : null; return simpleNotification; }