【问题标题】:Discern "ongoing" notifciations in AccessibilityService?辨别 AccessibilityService 中的“持续”通知?
【发布时间】:2013-08-10 11:15:02
【问题描述】:

在新的 JB-4.3 NotificationListenerService 中,每个 StatusBarNotification 对象都有一个isOngoing() 方法来查看它是否是一个持久通知。 AccessibilityService 也可以这样做吗?我已将事件转换为Notification,但这相当于sbn.getNotification()(因此没有ongoingproperty)。

另外,有没有办法使用AccessibilityService 清除现有的状态栏通知?

【问题讨论】:

    标签: android notifications


    【解决方案1】:

    正如您在StatusBarNotification.java 中看到的,isOngoing() 只是查看标志:

    public boolean isOngoing() {
        return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
    }
    

    所以你也可以这样做。

    没有办法使用无障碍服务来清除通知——这就是创建 NotificationListenerService 的原因。 :)

    【讨论】:

    • 太棒了,非常感谢您的回答!我从没想过要查看StatusBarNotification-source,因为我确信它正在做一些 4.3-only-magic :-)!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多