【问题标题】:How to Clear other apps Notification from status bar progmatically in rooted device如何在根设备中以编程方式从状态栏中清除其他应用程序通知
【发布时间】:2018-07-31 11:44:13
【问题描述】:

我正在使用有根设备,我想以编程方式从状态栏中清除其他应用程序通知。 我试过这个:

NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();

但这不适用于我的平板电脑

【问题讨论】:

标签: android


【解决方案1】:

似乎从 API 18 开始,此方法 (notificationManager.cancellAll()) 不再按预期工作,但我不确定。看起来您需要创建侦听器,它将在创建和取消通知时进行侦听,将其对象存储在某处,然后您将能够删除对象并取消通知。

查看此答案了解详情:https://stackoverflow.com/a/31233518/1150795

【讨论】:

  • 有没有其他方法可以在不存储所有id的情况下清除它
  • 也许有,但我不知道。如果 manager.cancellAll() 不起作用(如果它在 API 中并且未被弃用,IMO 应该这样做),我会收集所有通知 ID 并在循环中单独取消每个通知。
猜你喜欢
  • 2023-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多