当前位置: 首页>>代码示例>>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;未经允许,请勿转载。