【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
相关推荐
百***618722 分钟前
Spring的构造注入
android·java·spring
Tom4i28 分钟前
Kotlin 中的 inline 和 reified 关键字
android·开发语言·kotlin
yi诺千金1 小时前
Android U 自由窗口(浮窗)——启动流程(system_server侧流程)
android
清空mega4 小时前
第11章 网络编程
android·网络
自动化BUG制造器4 小时前
Android UI 线程不一定是主线程
android
无知的前端4 小时前
一文读懂-Jetpack与AndroidX
android·kotlin·android jetpack
河铃旅鹿5 小时前
Android开发-java版:SQLite数据库
android·数据库·笔记·学习·sqlite
旋律逍遥6 小时前
《Framework 开发》3、开发工具及命令行知识装备
android
啦啦9117146 小时前
安卓手机/平板/TV版 Rotation强制横屏显示工具!免ROOT可用!再推荐突破手机限制的3款神器
android·智能手机·电脑
汤面不加鱼丸7 小时前
flutter实践:混合app在部分android旧机型上显示异常
android·flutter