从其他应用程序的通知栏删除通知 [英] Remove notification from notification bar from other applications

查看:177
本文介绍了从其他应用程序的通知栏删除通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从在通知栏中显示的另一个应用程序中删除的通知。那可能吗? NotificationManager.cancelAll(); 取消只能通过调用应用程序显示通知,据我所知

I want to remove notifications from another application shown in the notification bar. Is that possible? NotificationManager.cancelAll(); cancels only notifications shown by the calling application, as far as I know.

我为什么要这么做?

我有读取,并通过网页发送短信的应用程序,我想这个应用程序共同退出与现有的短信应用,如Handcent短信。我希望它的工作方式是,当读通过网页新收到的短信,我想取消由Handcent短信显示新短信通知,因为新的短信,现在读。我标志着手机短信为已读,并Handcent短信识别为我打开Handcent短信读取一次,但通知仍然存在,直到我点击的实际短信。

I have an application that reads and sends SMS via a webpage, and I want this application to co-exits with existing SMS applications like Handcent SMS. The way I want it to work is that when reading newly received SMS via the webpage, I want to cancel the new SMS notification shown by Handcent SMS because the new SMS is now read. I'm marking the SMS as read, and Handcent SMS recognize it as read once i open up Handcent SMS, but the notification is still there until i click on the actual SMS.

有两种senarios;号码1:

There are two senarios; number 1:

  1. 在Android设备接收到一个短信。
  2. 的通知显示由Handcent短信。
  3. 在用户读取设备上的短信。
  4. 在Handcent短信删除通知,标志着该短信为已读。

塞纳里奥2:

  1. 在Android设备接收到一个短信。
  2. 的通知显示由Handcent短信。
  3. 在用户读取通过Web界面的短信。
  4. 在我的应用程序清除受Handcent短信显示新短信通知,标志着该短信为已读。

这可能吗?

问候, 约翰·

推荐答案

从安卓4.3开始,你现在可以从任何应用程序的取消通知。

From Android 4.3 onward, you can now cancel notifications from any apps.

您需要注册您的应用程序的<一个href="http://developer.android.com/reference/android/service/notification/NotificationListenerService.html"><$c$c>NotificationListenerService,然后调用 NotificationListenerService.cancelNotification(PKG字符串,字符串变量,INT ID)取消一个通知。

You need to register your app as NotificationListenerService, then call NotificationListenerService.cancelNotification(String pkg, String tag, int id) to cancel one notification.

这篇关于从其他应用程序的通知栏删除通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆