【问题标题】:How to remove notification from status bar when clicking the my footer icon单击我的页脚图标时如何从状态栏中删除通知
【发布时间】:2019-06-25 12:44:16
【问题描述】:

我想在单击页脚图标时从状态栏中删除通知。如何在服务类外调用该方法:

 mNotificationManager.cancel(MY_NOTIFICATION_ID); 

是否有其他解决方案可以通过单击自定义按钮来删除通知?

【问题讨论】:

  • 不是删除通知吗?
  • 收到通知时,应用程序处于前台,然后我单击页脚图标打开通知活动。那时我需要从状态栏中删除通知。

标签: android firebase android-notifications


【解决方案1】:

您可以通过这种方式在服务类之外调用通知(例如使用按钮单击的活动):

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(MY_NOTIFICATION_ID);

你可以在https://developer.android.com/training/notify-user/build-notification#Removing看到它的详细信息。

【讨论】:

    猜你喜欢
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-15
    • 2013-10-26
    • 1970-01-01
    相关资源
    最近更新 更多