【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
相关推荐
奔跑吧 android12 小时前
【车载Audio】【AudioHal 06】【高通音频架构】【深入浅出 Android Audio HAL:从加载到函数指针绑定的全链路解析】
android·音视频·audioflinger·aosp13·8295·audiohal·高通音频架构
无巧不成书021812 小时前
Kotlin Multiplatform (KMP) 鸿蒙开发整合实战|2026最新方案
android·开发语言·kotlin·harmonyos·kmp
恋猫de小郭21 小时前
丰田正在使用 Flutter 开发游戏引擎 Fluorite
android·前端·flutter
似霰1 天前
Unix Domain Socket —— UDP 篇
android·unix
独自破碎E1 天前
BISHI54货物堆放
android·java·开发语言
冬奇Lab1 天前
属性系统与系统配置管理:Android的全局配置中心
android·源码阅读
zjttsh1 天前
MySQL加减间隔时间函数DATE_ADD和DATE_SUB的详解
android·数据库·mysql
fengsen52113141 天前
MySQL--》如何在MySQL中打造高效优化索引
android·mysql·adb