从状态栏删除的通知图标 [英] Remove the notification icon from the status bar

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

问题描述

我在显示状态的图标bar.Now我想,如果我们收到任何警报立即删除图标,当我打开的内容,经过一段时间后,该图标会再次出现。我怎样才能做到这一点?

I am displaying an icon in status bar.Now I want to remove that icon immediately when I open that content, after some time if we receive any alert, that icon will be displayed again. How can I do this?

推荐答案

使用的NotificationManager取消通知。您只需要提供您的通知ID

Use the NotificationManager to cancel your notification. You only need to provide your notification id

<一个href="http://developer.android.com/intl/de/reference/android/app/NotificationManager.html">http://developer.android.com/intl/de/reference/android/app/NotificationManager.html

private static final int MY_NOTIFICATION_ID= 1234;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(MY_NOTIFICATION_ID, notification);

这个例子code是不完整的。这取决于你如何创建您的通知。 只要确保你用相同的ID取消通知你,当你创建的通知使用。

The example code is not complete. It depends on how your created your notification. Just make sure you use the same id to cancel your notification as you used when you created your notification.

要取消:

mNotificationManager.cancel(MY_NOTIFICATION_ID);

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

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