【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
相关推荐
明川1 天前
Android Gradle - ASM + AsmClassVisitorFactory插桩使用
android·前端·gradle
csdn12259873361 天前
Android将应用添加到默认打开方式
android
百锦再1 天前
京东云鼎入驻方案解读——通往协同的“高架桥”与“快速路”
android·java·python·rust·django·restful·京东云
成都大菠萝1 天前
1-2-3 Kotlin与C++基础-JNI原理与使用
android
TimeFine1 天前
Android AI解放生产力(六)实战:解放页面开发前的繁琐工作
android·架构
心静财富之门1 天前
a.py打包加密
android
成都大菠萝1 天前
1-2-2 Kotlin与C++基础-C++基础语法与内存管理
android
陈希瑞1 天前
【保姆级教程】安卓手机免Root一键部署AutoGLM:支持语音控制与自动化操作
android·智能手机·自动化
TheNextByte11 天前
如何将联系人从Android传输到计算机的 6 种方法
android
喂_balabala1 天前
excludeFromRecents
android