【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
相关推荐
d***93513 小时前
springboot3.X 无法解析parameter参数问题
android·前端·后端
s***117018 小时前
Mysql convert函数、convert用法、字符串转数字、字符串转日期、类型转换函数
android·数据库·mysql
n***265619 小时前
【MySQL】MVCC详解, 图文并茂简单易懂
android·数据库·mysql
程序猿陌名!19 小时前
Android-EDLA RK3576谷歌ATTESTION-KEY从申请到烧录以及验证谷歌认证标志全流程
android
安卓理事人19 小时前
安卓版本升级功能
android
s***353019 小时前
怎么下载安装yarn
android·前端·后端
z***948419 小时前
使用rustDesk搭建私有远程桌面
android·前端·后端
q***062919 小时前
【细如狗】记录一次使用MySQL的Binlog进行数据回滚的完整流程
android·数据库·mysql
0***863319 小时前
图文详述:MySQL的下载、安装、配置、使用
android·mysql·adb
9***446319 小时前
SQLyog安装配置(注册码)连接MySQL
android·mysql·adb