本文整理匯總了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();
}
}
}
示例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);
}
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
}
}
示例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)));
}
}
示例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);
}
}
}
示例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;
}
}
}
示例10: isPermissionNotification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
boolean isPermissionNotification(StatusBarNotification sbn) {
if (getPackageName().equals(sbn.getPackageName()) && 2 == sbn.getId()) {
return true;
}
return false;
}