【Android】SystemUI通知栏过滤指定应用的通知

需求

通知栏显示过多通知,有的是前台服务,客户反馈有的前台服务点不进去,不想让它出现在通知栏.

所以让其在添加显示时过滤掉即可。

修改

NotificationListener.java --- Android9

StatusBar.java --- Android8.1

onNotificationPosted ---- 更新通知栏通知的方法

java 复制代码
public void onNotificationPosted(final StatusBarNotification sbn,
            final RankingMap rankingMap) {
    //add isSoundNotification function to skip sound services notification 20240325
    if (sbn != null && !onPluginNotificationPosted(sbn, rankingMap) && !isSoundNotification(sbn)) {
        ....
    }
}

    //add  for skip sound notification 20240325 start
    private boolean isSoundNotification(StatusBarNotification statusBarNotification) {
        Log.i(TAG,"isSoundNotification package name = " + statusBarNotification.getPackageName());
        return statusBarNotification.getPackageName().contains("xxx.xxx.xxx");
    }
    //add  for skip sound notification 20240325 end
相关推荐
小七有话说42 分钟前
DevUI与企业级中后台系统融合:低代码表单构建器实战
android·rxjava·devui
暗碳2 小时前
安卓abx二进制xml文件转换普通xml文件
android·xml
4z332 小时前
Android15 Framework(3):系统服务进程 SystemServer 解析
android·源码阅读
没有了遇见2 小时前
Android 之Google Play bundletool 校验 AAB包
android·google
yuanhello3 小时前
【Android】Android的键值对存储方案对比
android·java·android studio
Ditglu.3 小时前
CentOS7 MySQL5.7 主从复制最终版搭建流程(避坑完整版)
android·adb
恋猫de小郭3 小时前
Android Studio Otter 2 Feature 发布,最值得更新的 Android Studio
android·前端·flutter
走在路上的菜鸟3 小时前
Android学Dart学习笔记第十二节 函数
android·笔记·学习·flutter
没有了遇见3 小时前
Android + Google Play:老项目适配实战指南
android·google
怀君3 小时前
Uniapp——开发Android插件教程
android·uni-app