當前位置: 首頁>>代碼示例>>Java>>正文


Java StatusBarNotification.getId方法代碼示例

本文整理匯總了Java中android.service.notification.StatusBarNotification.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java StatusBarNotification.getId方法的具體用法?Java StatusBarNotification.getId怎麽用?Java StatusBarNotification.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.service.notification.StatusBarNotification的用法示例。


在下文中一共展示了StatusBarNotification.getId方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cancelActiveNotifications

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private static void cancelActiveNotifications(@NonNull Context context) {
  NotificationManager notifications = ServiceUtil.getNotificationManager(context);
  notifications.cancel(SUMMARY_NOTIFICATION_ID);

  if (Build.VERSION.SDK_INT >= 23) {
    try {
      StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();

      for (StatusBarNotification activeNotification : activeNotifications) {
        if (activeNotification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION) {
          notifications.cancel(activeNotification.getId());
        }
      }
    } catch (Throwable e) {
      // XXX Appears to be a ROM bug, see #6043
      Log.w(TAG, e);
      notifications.cancelAll();
    }
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:MessageNotifier.java

示例2: clear

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@Override
void clear(Chat chat, NotificationBuilder nb) {
    int id = (int) chat.getUniqueId();

    nb.getNotificationManager().cancel(id);

    boolean clearGroup = true;
    for (StatusBarNotification sbn : nb.getNotificationManager().getActiveNotifications()) {
        if (sbn.getId() != NOTIFICATION_ID_SYSTEM
                && sbn.getId() != NOTIFICATION_ID_GROUP_SUMMARY) {
            clearGroup = false;
        }
    }
    if (clearGroup) {
        nb.getNotificationManager().cancel(NOTIFICATION_ID_GROUP_SUMMARY);
    }
}
 
開發者ID:RikkaApps,項目名稱:FCM-for-Mojo,代碼行數:18,代碼來源:NotificationBuilderImplBase.java

示例3: findExistItem

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private NotificationBarInfoItem findExistItem(StatusBarNotification statusBarNotification) {
    if (statusBarNotification == null || statusBarNotification.getPackageName() == null) {
        return null;
    }
    if (CollectionUtils.isEmpty(notificationInfo.getData())) {
        return null;
    }
    CharSequence packageName = statusBarNotification.getPackageName();
    int id = statusBarNotification.getId();
    for (NotificationBarInfoItem notificationBarInfoItem : notificationInfo.getData()) {
        if (id == notificationBarInfoItem.getNotifyId() && TextUtils.equals(packageName, notificationBarInfoItem.getPackageName()) && notificationBarInfoItem.getType() == 1) {
            return notificationBarInfoItem;
        }
    }
    return null;
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:17,代碼來源:NotificationListener.java

示例4: notificationFromStatusBarNotification

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@TargetApi(21)
Notification notificationFromStatusBarNotification(StatusBarNotification sbn) {
    if (VERSION.SDK_INT < 21) {
        return new Notification(sbn.getPackageName(), sbn.getId(), sbn.getTag(), null, sbn.getNotification());
    }
    return new Notification(sbn.getPackageName(), sbn.getId(), sbn.getTag(), sbn.getKey(), sbn.getNotification());
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:8,代碼來源:NotificationService.java

示例5: createParcelableNotification

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private Notification createParcelableNotification(StatusBarNotification sbn) {
	Notification notification = new Notification(sbn.getId());
	if (sbn.getNotification().tickerText == null || sbn.getNotification().tickerText.toString().isEmpty()) {
		Log.d(TAG, "ignoring null notification");
		return null;
	}
	if (sbn.getNotification().tickerText != null)
		notification.setTickerText(sbn.getNotification().tickerText.toString());
	if (sbn.getNotification().contentIntent.getCreatorPackage() != null)
		notification.setCreatorPackage(sbn.getNotification().contentIntent.getCreatorPackage());
	return notification;
}
 
開發者ID:masterjc,項目名稱:bluewatcher,代碼行數:13,代碼來源:WatchNotificationListener.java

示例6: cancelOrphanedNotifications

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private static void cancelOrphanedNotifications(@NonNull Context context, NotificationState notificationState) {
  if (Build.VERSION.SDK_INT >= 23) {
    try {
      NotificationManager     notifications       = ServiceUtil.getNotificationManager(context);
      StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();

      for (StatusBarNotification notification : activeNotifications) {
        boolean validNotification = false;

        if (notification.getId() != SUMMARY_NOTIFICATION_ID &&
                notification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION   &&
                notification.getId() != KeyCachingService.SERVICE_RUNNING_ID          &&
                notification.getId() != MessageRetrievalService.FOREGROUND_ID)
        {
          for (NotificationItem item : notificationState.getNotifications()) {
            if (notification.getId() == (SUMMARY_NOTIFICATION_ID + item.getThreadId())) {
              validNotification = true;
              break;
            }
          }

          if (!validNotification) {
            notifications.cancel(notification.getId());
          }
        }
      }
    } catch (Throwable e) {
      // XXX Android ROM Bug, see #6043
      Log.w(TAG, e);
    }
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:33,代碼來源:MessageNotifier.java

示例7: containsSameNotification

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
public boolean containsSameNotification(StatusBarNotification other) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        return contentNotification.getKey().equals(other.getKey());
    } else {
        return (contentNotification.getPackageName().equals(other.getPackageName()) &&
                (contentNotification.getId() == other.getId()) &&
                ((contentNotification.getTag() != null && contentNotification.getTag().equals(other.getTag())) || (contentNotification.getTag() == null && other.getTag() == null)));
    }
}
 
開發者ID:matejdro,項目名稱:WearVibrationCenter,代碼行數:10,代碼來源:ProcessedNotification.java

示例8: cancelOrphanedNotifications

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private static void cancelOrphanedNotifications(@NonNull Context context, NotificationState notificationState) {
  if (Build.VERSION.SDK_INT >= 23) {
    try {
      NotificationManager     notifications       = ServiceUtil.getNotificationManager(context);
      StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();

      for (StatusBarNotification notification : activeNotifications) {
        boolean validNotification = false;

        if (notification.getId() != SUMMARY_NOTIFICATION_ID &&
            notification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION   &&
            notification.getId() != KeyCachingService.SERVICE_RUNNING_ID          &&
            notification.getId() != MessageRetrievalService.FOREGROUND_ID         &&
            notification.getId() != PENDING_MESSAGES_ID)
        {
          for (NotificationItem item : notificationState.getNotifications()) {
            if (notification.getId() == (SUMMARY_NOTIFICATION_ID + item.getThreadId())) {
              validNotification = true;
              break;
            }
          }

          if (!validNotification) {
            notifications.cancel(notification.getId());
          }
        }
      }
    } catch (Throwable e) {
      // XXX Android ROM Bug, see #6043
      Log.w(TAG, e);
    }
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:34,代碼來源:MessageNotifier.java

示例9: OnNotificationRemoved

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@Override
public void OnNotificationRemoved(int ID) {
    for(int s = 0; s < sbNotifications.size(); s++){
        StatusBarNotification sbn = sbNotifications.get(s);
        if(sbn.getId() == ID){
            sbNotifications.remove(s);
            if(s == sbNotifications.size()){
                s--;
            }
            //updateNotifications(s);
            break;
        }
    }

}
 
開發者ID:ordsen,項目名稱:Snach-Android,代碼行數:16,代碼來源:BLEManager.java

示例10: isPermissionNotification

import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
boolean isPermissionNotification(StatusBarNotification sbn) {
    if (getPackageName().equals(sbn.getPackageName()) && 2 == sbn.getId()) {
        return true;
    }
    return false;
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:7,代碼來源:NotificationService.java


注:本文中的android.service.notification.StatusBarNotification.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。