【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
相关推荐
云水木石1 小时前
Android 的下一个战场:Windows 应用与游戏?
android·windows·游戏
雨声不在2 小时前
Android文字渐变的实现
android·textview
GoldenPlayer2 小时前
KTS语法
android
GoldenPlayer2 小时前
后台服务Service销毁逻辑+单例造成的内存泄露
android
GoldenPlayer2 小时前
自定义APK&gradle全局配置文件
android
うちは止水2 小时前
Android Hal层开发流程
android·hal
李小轰_Rex2 小时前
把手机变成听诊器!摄像头 30 秒隔空测心率 - 开箱即用
android·音视频开发
为码消得人憔悴4 小时前
Android perfetto - 记录分析memory
android·性能优化
尤老师FPGA4 小时前
使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第四十二讲)
android·java·ui
成都大菠萝5 小时前
2-2-29 快速掌握Kotlin-过滤函数filter
android