【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
相关推荐
Jerry21 小时前
Compose 的阶段
android
Zhangzy@1 天前
Rust 编译优化选项
android·开发语言·rust
某空m1 天前
【Android】View滑动的实现
android
芝麻开门-新起点1 天前
Android 和 iOS 系统版本及开发适配
android·ios·cocoa
2501_915918411 天前
iOS描述文件功能解析
android·macos·ios·小程序·uni-app·cocoa·iphone
用户69371750013841 天前
一文彻底搞懂 Android 依赖配置:implementation vs testImplementation,再也不混淆!
android
TimeFine1 天前
Android WebView暗夜模式适配
android
studyForMokey1 天前
【Android Activity】生命周期深入理解
android·kotlin
浅影歌年1 天前
Android 嵌入h5顶部状态栏空白
android
来来走走1 天前
kotlin学习 lambda编程
android·学习·kotlin