我正在制作聊天应用程序,我要求用户退出应用程序时,应该从通知栏中删除我的应用程序的所有通知。
有可能吗?
由于
答案 0 :(得分:2)
我相信这会解决问题:
http://developer.android.com/reference/android/app/NotificationManager.html#cancelAll()
或者您也可以通过ID取消它们:
http://developer.android.com/reference/android/app/NotificationManager.html#cancel(int)
答案 1 :(得分:1)
是的,使用NotificationManager.cancelAll()
http://developer.android.com/reference/android/app/NotificationManager.html#cancelAll()
答案 2 :(得分:1)
是的,看看这里:
Remove the notification icon from the status bar
您只需提供通知ID;仅删除您的申请通知。
当用户退出或活动转到onPause()或onStop()(取决于您的需要)时,您使用:
public void cancel (String tag, int id)
取消之前显示的通知。如果它是瞬态的,视图将被隐藏。如果它是持久的,它将从状态栏中删除。