Java Code Examples for android.service.notification.StatusBarNotification#getTag()
The following examples show how to use
android.service.notification.StatusBarNotification#getTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationListenerService.java From heads-up with GNU General Public License v3.0 | 6 votes |
public boolean isNotificationValid(String pkg, String tag, int id) { final StatusBarNotification[] activeNotifications = getActiveNotifications(); for (StatusBarNotification statusBarNotification : activeNotifications) { final String statusBarNotificationTag = statusBarNotification.getTag(); final String statusBarNotificationPackageName = statusBarNotification.getPackageName(); final int statusBarNotificationId = statusBarNotification.getId(); if (statusBarNotificationPackageName.equals(pkg) && statusBarNotificationId == id) { if (tag == null && statusBarNotificationTag == null) return true; if (tag != null && statusBarNotificationTag != null) if (statusBarNotificationTag.equals(tag)) return true; } } return false; }
Example 2
Source File: NotificationObject.java From android-notification-log with MIT License | 5 votes |
NotificationObject(Context context, StatusBarNotification sbn, final boolean LOG_TEXT, int reason) { this.context = context; this.LOG_TEXT = LOG_TEXT; n = sbn.getNotification(); packageName = sbn.getPackageName(); postTime = sbn.getPostTime(); systemTime = System.currentTimeMillis(); isClearable = sbn.isClearable(); isOngoing = sbn.isOngoing(); nid = sbn.getId(); tag = sbn.getTag(); if(Build.VERSION.SDK_INT >= 20) { key = sbn.getKey(); sortKey = n.getSortKey(); } removeReason = reason; extract(); if(Const.ENABLE_ACTIVITY_RECOGNITION || Const.ENABLE_LOCATION_SERVICE) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); lastActivity = sp.getString(Const.PREF_LAST_ACTIVITY, null); lastLocation = sp.getString(Const.PREF_LAST_LOCATION, null); } }
Example 3
Source File: ProgressBarController.java From GravityBox with Apache License 2.0 | 5 votes |
private String getIdentifier(StatusBarNotification statusBarNotif) { if (statusBarNotif == null) return null; String pkgName = statusBarNotif.getPackageName(); if (SUPPORTED_PACKAGES.get(0).equals(pkgName)) { String tag = statusBarNotif.getTag(); if (tag != null && tag.contains(":")) { return pkgName + ":" + tag.substring(tag.indexOf(":")+1); } if (DEBUG) log("getIdentifier: Unexpected notification tag: " + tag); } else { return (pkgName + ":" + String.valueOf(statusBarNotif.getId())); } return null; }
Example 4
Source File: NotUsedMobileCellsNotificationDisableReceiver.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { //PPApplication.logE("##### NotUsedMobileCellsNotificationDisableReceiver.onReceive", "xxx"); //CallsCounter.logCounter(context, "NotUsedMobileCellsNotificationDisableReceiver.onReceive", "NotUsedMobileCellsNotificationDisableReceiver_onReceive"); SharedPreferences.Editor editor = ApplicationPreferences.getEditor(context.getApplicationContext()); editor.putBoolean(ApplicationPreferences.PREF_APPLICATION_EVENT_MOBILE_CELL_NOT_USED_CELLS_DETECTION_NOTIFICATION_ENABLED, false); editor.apply(); ApplicationPreferences.applicationEventMobileCellNotUsedCellsDetectionNotificationEnabled(context.getApplicationContext()); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (manager != null) { //if (Build.VERSION.SDK_INT >= 23) { StatusBarNotification[] notifications = manager.getActiveNotifications(); for (StatusBarNotification notification : notifications) { String tag = notification.getTag(); if ((tag != null) && tag.contains(PPApplication.NEW_MOBILE_CELLS_NOTIFICATION_TAG+"_")) { if (notification.getId() >= PPApplication.NEW_MOBILE_CELLS_NOTIFICATION_ID) { manager.cancel(notification.getTag(), notification.getId()); } } } /*} else { int notificationId = intent.getIntExtra("notificationId", 0); manager.cancel(notificationId); }*/ } }
Example 5
Source File: Permissions.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
static void removeProfileNotification(Context context) { try { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.cancel( PPApplication.GRANT_PROFILE_PERMISSIONS_NOTIFICATION_TAG, PPApplication.GRANT_PROFILE_PERMISSIONS_NOTIFICATION_ID); //if (Build.VERSION.SDK_INT >= 23) { StatusBarNotification[] notifications = notificationManager.getActiveNotifications(); for (StatusBarNotification notification : notifications) { String tag = notification.getTag(); if ((tag != null) && tag.contains(PPApplication.GRANT_PROFILE_PERMISSIONS_NOTIFICATION_TAG+"_")) { if (notification.getId() >= PPApplication.PROFILE_ID_NOTIFICATION_ID) { notificationManager.cancel(notification.getTag(), notification.getId()); } } } /*} else { int notificationId = intent.getIntExtra("notificationId", 0); manager.cancel(notificationId); }*/ } } catch (Exception e) { PPApplication.recordException(e); } }
Example 6
Source File: Permissions.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
static void removeEventNotification(Context context) { try { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.cancel( PPApplication.GRANT_EVENT_PERMISSIONS_NOTIFICATION_TAG, PPApplication.GRANT_EVENT_PERMISSIONS_NOTIFICATION_ID); //if (Build.VERSION.SDK_INT >= 23) { StatusBarNotification[] notifications = notificationManager.getActiveNotifications(); for (StatusBarNotification notification : notifications) { String tag = notification.getTag(); if ((tag != null) && tag.contains(PPApplication.GRANT_EVENT_PERMISSIONS_NOTIFICATION_TAG+"_")) { if (notification.getId() >= PPApplication.EVENT_ID_NOTIFICATION_ID) { notificationManager.cancel(notification.getTag(), notification.getId()); } } } /*} else { int notificationId = intent.getIntExtra("notificationId", 0); manager.cancel(notificationId); }*/ } } catch (Exception e) { PPApplication.recordException(e); } }
Example 7
Source File: NotificationHelper.java From NotificationPeekPort with Apache License 2.0 | 5 votes |
public static String getContentDescription(StatusBarNotification content) { if (content != null) { String tag = content.getTag() == null ? "null" : content.getTag(); return content.getPackageName() + DELIMITER + content.getId() + DELIMITER + tag; } return null; }
Example 8
Source File: NotificationLayout.java From NotificationPeekPort with Apache License 2.0 | 5 votes |
@Override public void onChildDismissed(View v) { StatusBarNotification n = (StatusBarNotification) mNotificationPeek.getNotificationView().getTag(); String pkg = n.getPackageName(); String tag = n.getTag(); int id = n.getId(); // Dismiss action confirmed, we need to remove the current notification. mNotificationPeek .onChildDismissed(NotificationHelper.getContentDescription(n), pkg, tag, id); mNotificationPeek.setAnimating(false); }