【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
相关推荐
冬奇Lab4 分钟前
Android 15 显示子系统深度解析(二):图形缓冲区管理与HWC硬件合成
android
wings专栏7 分钟前
Android触摸事件分发记录
android
aaajj20 分钟前
【Android】声控拍照例子
android
stevenzqzq23 分钟前
Android MVI 中 setState(reduce: State.() -> State) 设计说明文档
android·mvi框架
鸣弦artha37 分钟前
Flutter框架跨平台鸿蒙开发——InheritedWidget基础使用-计数器案例
android·flutter·harmonyos
嵌入式-老费1 小时前
Android开发(开发板的三种操作系统)
android
凛_Lin~~2 小时前
安卓网络框架——OkHttp源码解析(基于3.14.x)
android·网络·okhttp
stevenzqzq2 小时前
android SharedFlow和Channel比较
android·channel·sharedflow
zhangphil2 小时前
Kotlin实现Glide/Coil图/视频加载框架(二)
android·kotlin
shughui2 小时前
APP、Web、H5、iOS与Android的区别及关系
android·前端·ios