【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
相关推荐
折翅鵬5 小时前
Android史诗级网络优化实践总结
android·网络
赏金术士7 小时前
Android 项目模块化与 Feature 组件实践
android·kotlin·模块化
summerkissyou198711 小时前
Android-UI-获取屏幕尺寸的方法
android·ui
用户860225046747211 小时前
Kotlin 函数式编程入门与实践指南
android
最爱睡觉睡觉睡觉12 小时前
CSS → Flutter 对照手册
android·前端
xingpanvip13 小时前
星盘接口开发文档:马盘次限盘接口指南
android·开发语言·python·php·lua
用户261904985615713 小时前
JUnit4 完整配置流程
android
用户261904985615714 小时前
JaCoCo 完整配置流程
android
QING61814 小时前
Android面试 —— 八股文之app启动流程
android·面试·app
海鸥-w14 小时前
python(fastapi) 实现更新,新增,删除接口
android·python·fastapi