【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
相关推荐
火柴就是我37 分钟前
Flutter 混合模式下:saveLayer 混合注意点
android·flutter
Mintopia1 小时前
🎙️ React Native(RN)语音输入场景全解析
android·react native·aigc
centor1 小时前
国际版 UnitySetup-Android-Support 安装 Mac 设备
android·macos
城东米粉儿1 小时前
compose 中的附带效应笔记一
android
STCNXPARM2 小时前
Android14显示系统 - VSYNC机制
android·surfaceflinger·vsync
say_fall2 小时前
C++ 类与对象易错点:初始化列表顺序 / 静态成员访问 / 隐式类型转换
android·java·开发语言·c++
落羽凉笙2 小时前
Python基础(4)| 详解程序选择结构:单分支、双分支与多分支逻辑(附代码)
android·服务器·python
携欢2 小时前
portswigger靶场之修改序列化数据类型通关秘籍
android·前端·网络·安全
·云扬·3 小时前
MySQL四大系统库详解:作用、核心表与实用SQL查询
android·sql·mysql
普马萨特3 小时前
移动网络信号指标与单位整理(2G/3G/4G/5G Android vs IoT)
android·网络·物联网