【问题标题】:Android cancel notification安卓取消通知
【发布时间】:2011-12-15 04:49:43
【问题描述】:

我有一个后台服务正在运行以获取数据。我检查新数据并发送状态栏通知。发送通知是服务的一部分。当用户看到该通知时,他登录到应用程序并接受它。那个时候我想从状态栏中删除它。我可以这样做吗?

【问题讨论】:

标签: android


【解决方案1】:
if (Context.NOTIFICATION_SERVICE!=null) {
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(ns);
        nMgr.cancel(0);
    }

在第二个类中编写上面的代码,并在第一个类中使用 id 0 创建通知。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-20
  • 2017-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多