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


Java NotificationManager.cancel方法代碼示例

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


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

示例1: onAction

import android.app.NotificationManager; //導入方法依賴的package包/類
@Override
public void onAction(Object actionData) {
    if (!(actionData instanceof ActionDataInfo)) {
        DownloadManagerService.openDownloadsPage(mContext);
        return;
    }
    final ActionDataInfo download = (ActionDataInfo) actionData;
    if (download.downloadInfo.isOfflinePage()) {
        OfflinePageDownloadBridge.openDownloadedPage(download.downloadInfo.getDownloadGuid());
        return;
    }
    DownloadManagerService manager = DownloadManagerService.getDownloadManagerService(mContext);
    manager.openDownloadedContent(download.downloadInfo, download.systemDownloadId);
    if (download.notificationId != INVALID_NOTIFICATION_ID) {
        NotificationManager notificationManager =
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(
                DownloadNotificationService.NOTIFICATION_NAMESPACE, download.notificationId);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:21,代碼來源:DownloadSnackbarController.java

示例2: cancelNotifs

import android.app.NotificationManager; //導入方法依賴的package包/類
public void cancelNotifs(){
    if(feed instanceof Feed) {
        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.cancel(feed.getOrder());
    }

}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:8,代碼來源:FeedLoader.java

示例3: cancelOrphanedNotifications

import android.app.NotificationManager; //導入方法依賴的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

示例4: cancel

import android.app.NotificationManager; //導入方法依賴的package包/類
/**
 * Cancels any notifications of this type previously shown using
 */
@TargetApi(Build.VERSION_CODES.ECLAIR)
static void cancel(final Context context) {
    final NotificationManager nm = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        nm.cancel(TRAIN_NOTIFICATION_TAG, 0);
    } else {
        nm.cancel(TRAIN_NOTIFICATION_TAG.hashCode());
    }
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:14,代碼來源:TrainNotification.java

示例5: cancleNotification

import android.app.NotificationManager; //導入方法依賴的package包/類
/**
 * Cancels the notification.
 */
private void cancleNotification() {
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.cancel(getNotificationId());

}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:11,代碼來源:LocalImagePlayer.java

示例6: onReceive

import android.app.NotificationManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    NotificationManager notificationManager= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder=new NotificationCompat.Builder(context);
     switch (intent.getAction()){
         case UPLOADING_START:
             System.out.println("Please work");
             notificationManager.cancel(UPLOAD_ID);
             Log.d("reciever","start");
             builder.setContentTitle("Uploading the "+intent.getStringExtra(WORK));
             builder.setSmallIcon(R.drawable.person_icon);
             builder.setProgress(0,0,true);
             notificationManager.notify(UPLOAD_ID,builder.build());
             break;
         case UPLOADING_FINISH:
             notificationManager.cancel(UPLOAD_ID);
             Log.d("reciever","finish");
             builder.setContentTitle("Finished Uploading the "+intent.getStringExtra(WORK));
             builder.setSmallIcon(R.drawable.person_icon);
             builder.setProgress(0,0,false);
             notificationManager.notify(UPLOAD_ID,builder.build());
             break;
         case UPLOADING_ERROR:
             notificationManager.cancel(UPLOAD_ID);
             Log.d("reciever","error");
             builder.setProgress(0,0,false);
             builder.setSmallIcon(R.drawable.person_icon);
             builder.setContentTitle("Error While Uploading the "+intent.getStringExtra(WORK));
             notificationManager.notify(UPLOAD_ID,builder.build());
             break;

     }
}
 
開發者ID:appteam-nith,項目名稱:Hillffair17,代碼行數:34,代碼來源:UploadBroadCastReceiver.java

示例7: cancelAll

import android.app.NotificationManager; //導入方法依賴的package包/類
public static final void cancelAll() {
    NotificationManager notificationManager = (NotificationManager) App.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.cancel(PUBLISH_STATUS_NOTIFICATION_REQUEST);
    notificationManager.cancel(REMIND_UNREAD_COMMENTS);
    notificationManager.cancel(REMIND_UNREAD_MENTION_COMMENTS);
    notificationManager.cancel(REMIND_UNREAD_MENTION_STATUS);
    notificationManager.cancel(REMIND_UNREAD_FOLLOWERS);
    notificationManager.cancel(REMIND_UNREAD_DM);
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:11,代碼來源:Notifier.java

示例8: removeNotification

import android.app.NotificationManager; //導入方法依賴的package包/類
private void removeNotification(int notificationId) {
    if (notificationId != NO_NOTIFICATION) {
        NotificationManager notificationManager = (NotificationManager) getActivity()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(notificationId);
    }
}
 
開發者ID:ad-on-is,項目名稱:chilly,代碼行數:8,代碼來源:VideoDetailsFragment.java

示例9: onReceive

import android.app.NotificationManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {

    ArrayList<User> currentUserList;
    Map<Integer, Integer> msgCountMap;

  //  MyApplication = (MyApplication) context.getApplicationContext();
    currentUserList = MyApplication.getInstance().getCurrentUserList();
    msgCountMap = MyApplication.getInstance().getMsgCountMap();

    String action = intent.getAction();
    Bundle msgNotifyBundle = intent.getExtras();
    int notifyId = msgNotifyBundle.getInt("notifyId");
    String qqPackgeName=msgNotifyBundle.getString("qqPackgeName");

    if (notifyId != -1) {
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(notifyId);
        for(int    i=0;    i<currentUserList.size();    i++){
            if(currentUserList.get(i).getNotifyId()==notifyId){
                currentUserList.get(i).setMsgCount("0");
                if(CurrentUserActivity.userHandler!=null)
                    new userThread().start();
                break;
            }
        }
    }

    if (action.equals("qq_notification_clicked")) {
        //處理點擊事件

            // 通過包名獲取要跳轉的app,創建intent對象
            Intent intentNewQq = context.getPackageManager().getLaunchIntentForPackage(qqPackgeName);

            if (intentNewQq != null) {
                if (msgCountMap.get(notifyId) != null)
                    msgCountMap.put(notifyId, 0);
                context.startActivity(intentNewQq);
            } else {
                // 沒有安裝要跳轉的app應用進行提醒
                Toast.makeText(context.getApplicationContext(), "未檢測到" + qqPackgeName, Toast.LENGTH_LONG).show();
            }

    }

    if (action.equals("qq_notification_cancelled")) {
        //處理滑動清除和點擊刪除事件
        if(msgCountMap.get(notifyId)!=null)
        msgCountMap.put(notifyId,0);
    }

}
 
開發者ID:heipidage,項目名稱:GcmForMojo,代碼行數:53,代碼來源:QqNotificationBroadcastReceiver.java

示例10: cancelOrphanedNotifications

import android.app.NotificationManager; //導入方法依賴的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

示例11: onNotifyRead

import android.app.NotificationManager; //導入方法依賴的package包/類
/**
 * 服務端主動發送已讀通知
 * @param readNotify
 */
public void onNotifyRead(IMMessage.IMMsgDataReadNotify readNotify){
    logger.d("chat#onNotifyRead");
    //發送此信令的用戶id
    long trigerId = readNotify.getUserId();
    long loginId = IMLoginManager.instance().getLoginId();
    if(trigerId != loginId){
        logger.i("onNotifyRead# trigerId:%s,loginId:%s not Equal",trigerId,loginId);
        return ;
    }
    //現在的邏輯是msgId之後的 全部都是已讀的
    // 不做複雜判斷了,簡單處理
    long msgId = readNotify.getMsgId();
    long peerId = readNotify.getSessionId();
    int sessionType = ProtoBuf2JavaBean.getJavaSessionType(readNotify.getSessionType());
    String sessionKey = EntityChangeEngine.getSessionKey(peerId,sessionType);

    // 通知欄也要去除掉
    NotificationManager notifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    if (notifyMgr == null) {
        return;
    }
    int notificationId = IMNotificationManager.instance().getSessionNotificationId(sessionKey);
    notifyMgr.cancel(notificationId);

    UnreadEntity unreadSession =  findUnread(sessionKey);
    if(unreadSession!=null && unreadSession.getLaststMsgId() <= msgId){
        // 清空會話session
        logger.d("chat#onNotifyRead# unreadSession onLoginOut");
        readUnreadSession(sessionKey);
    }
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:36,代碼來源:IMUnreadMsgManager.java

示例12: parseIntent

import android.app.NotificationManager; //導入方法依賴的package包/類
private void parseIntent() {
    if (getIntent() != null && getIntent().getExtras() != null) {
        String dnsModelJSON = getIntent().getExtras().getString("dnsModel", "");
        if (!dnsModelJSON.isEmpty()) {
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancel(1903);
            if (dnsList == null)
                getDNSItems();
            DNSModel model = gson.fromJson(dnsModelJSON, DNSModel.class);
            if (model.getName().equals(getString(R.string.custom_dns))) {
                firstDnsEdit.setText(model.getFirstDns());
                secondDnsEdit.setText(model.getSecondDns());
            } else {
                for (int i = 0; i < dnsList.size(); i++) {
                    DNSModel dnsModel = dnsList.get(i);
                    if (dnsModel.getName().equals(model.getName())) {
                        onClick(null, i);
                    }
                }
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    makeSnackbar(getString(R.string.dns_starting));
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    startButton.performClick();
                }
            });
        }
    }
}
 
開發者ID:msayan,項目名稱:star-dns-changer,代碼行數:36,代碼來源:MainActivity.java

示例13: sendNotifycation

import android.app.NotificationManager; //導入方法依賴的package包/類
private void sendNotifycation(int notifyId, int textId, int drawableId) {
    NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
    Notification notification = new Notification();
    PendingIntent contentIntent = PendingIntent.getActivity(this, notifyId, new Intent(), 0);
    notification.icon = drawableId;
    notification.tickerText = ShareUtils.getString(textId);
    notification.defaults |= 1;
    notification.flags = 16;
    notification.setLatestEventInfo(this, null, null, contentIntent);
    notificationManager.notify(notifyId, notification);
    notificationManager.cancel(notifyId);
    if (LetvUtils.getBrandName().toLowerCase().contains("xiaomi")) {
        ToastUtils.showToast((Context) this, textId);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:SharePageEditActivity.java

示例14: onTaskRemoved

import android.app.NotificationManager; //導入方法依賴的package包/類
@Override
public void onTaskRemoved(Intent rootIntent) {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);
}
 
開發者ID:pawelpaszki,項目名稱:youtube_background_android,代碼行數:6,代碼來源:BackgroundAudioService.java

示例15: cancelNotification

import android.app.NotificationManager; //導入方法依賴的package包/類
/** Cancel the ongoing notification that controls the connection state and play/stop*/
public static void cancelNotification(Context context, int id){
    NotificationManager mNotifyMgr =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotifyMgr.cancel(id);
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:7,代碼來源:NotificationUtils.java


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