【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
相关推荐
恋猫de小郭2 小时前
Flutter Analyzer 系列坑推进,必看,AI 时代这玩意最吃你内存
android·前端·flutter
LinXunFeng14 小时前
拿竞品 App 一扫,技术栈全暴露了
android·flutter·开源
Gracker16 小时前
AIW:从系统机制到性能排查,一本可以对照源码的 Android 电子书
android
三少爷的鞋17 小时前
代码越来越便宜,判断力越来越贵:AI 时代的 Android 架构与协程避坑指南
android
Gracker18 小时前
SmartPerfetto 1.19.0:换过分析引擎之后,这次更新了什么
android
HQL_seven1 天前
【Android】BroadcastReceiver 详解
android
_祝你今天愉快1 天前
Paint Cavans高级绘制:[二] Paint-滤镜,XFERMODE
android
小乖写代码1 天前
字段获取代码(Android) · Android Input Examples
android·whatsapp·账号注册
booboosui1 天前
停一个活只有杀进程:界面上少了「说点要求」
android
传奇开心果编程1 天前
【Flutter踩坑排雷】第28课:平台目录缺失与修复坑|`flutter create` 的“重建”与“覆盖”边界
android·flutter·ios·移动开发·跨平台·dart·声明式ui