【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
相关推荐
YXL1111YXL31 分钟前
LeakCanary 源码解析检测泄露工作机制(一)
android·leakcanary
且随疾风前行.2 小时前
Android Binder 驱动 - 内核驱动层源码初探
android·网络·binder
额恩663 小时前
AI 智能体从零搭建实战教程——扣子
android·rxjava·coze
hunterandroid3 小时前
前台服务适配与线上排查:通知权限、启动限制和任务保活
android·前端
帅次3 小时前
Android 高级工程师面试:Flutter 渲染与性能 近1年高频追问 20 题
android·flutter·面试·渲染·性能
糖果店的幽灵4 小时前
【langgraph 从入门到精通graphApi 篇】Command 与动态流程控制
android·java·数据库·人工智能·langgraph
Android-Flutter5 小时前
Android的http和https知识点
android·http·https
Kapaseker5 小时前
Sequence 一定比 List 快?等等,我们先从基础讲起
android·kotlin
AI刀刀5 小时前
deepseek 内容粘贴后符号丢失怎么办?AI 导出鸭实测解决排版乱码问题
android·人工智能·excel·ai导出鸭
东方佑6 小时前
Per-Group 混合精度量化:将 14B 视频生成模型压缩至 11 GB
android