【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
相关推荐
Bigger1 小时前
Flutter 开发实战:解决华为 HarmonyOS 任务列表不显示 App 名称的终极指南
android·flutter·华为
利剑 -~4 小时前
mysql面试题整理
android·数据库·mysql
梁同学与Android6 小时前
Android ---【经验篇】ArrayList vs CopyOnWriteArrayList 核心区别,怎么选择?
android·java·开发语言
沐怡旸7 小时前
【翻译】adb screenrecord 帮助文档
android
lienyin8 小时前
Android 简单的SFTP服务端+客户端通信传文件
android
fatiaozhang952713 小时前
中兴B860AV5.2-U_原机安卓4.4.2系统专用_晶晨S905L3SB处理器_线刷固件包
android·电视盒子·刷机固件·机顶盒刷机·中兴b860av5.2-u
儿歌八万首14 小时前
Android 自定义 View 实战:打造一个跟随滑动的丝滑指示器
android·kotlin
我有与与症14 小时前
Kuikly 实战:手把手撸一个跨平台 AI 聊天助手 (ChatDemo)
android
恋猫de小郭14 小时前
Flutter UI 设计库解耦重构进度,官方解答未来如何适配
android·前端·flutter
apihz14 小时前
全球IP归属地查询免费API详细指南
android·服务器·网络·网络协议·tcp/ip