【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
相关推荐
码农coding18 分钟前
android12 SystemUI之通知
android
summerkissyou19871 小时前
android - 性能 - Perfetto - cpu 分析教程及例子
android·性能
AFinalStone2 小时前
Android 7系统休眠唤醒(七)内核层—wakelock与autosleep机制
android·休眠唤醒
starvapour3 小时前
在关机键损坏的情况下让手机关机
android·adb·手机
AFinalStone4 小时前
Android 7系统休眠唤醒(五)休眠全链路
android·电源管理·休眠唤醒
zzq77975 小时前
Android 风险识别机制实测:从录屏悬浮窗到远程控制的边界评估
android·安全·安卓·app加固·御盾安全
码云数智-园园5 小时前
MySQL 慢查询排查完整流程
android
码云骑士5 小时前
【Android Performance】进程关联启动治理详解——从唤醒链分析到自启动管控的完整方案
android
心念枕惊6 小时前
PHP 在领域驱动(DDD)设计中的核心实践
android·开发语言·php
蜡台6 小时前
Android WebView 设计指南
android·java·kotlin