【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
相关推荐
zh_xuan21 小时前
kotlin runBlocking函数
android·kotlin·协程·runblocking
三少爷的鞋1 天前
别再 launch(IO) 了:协程线程切换的 3隐藏反模式
android
贤泽1 天前
Android 15 Lock Task 模式深度分析(第二部分)
android
huohuopro1 天前
Vue3 Webview 转 Android 虚拟导航栏遮挡问题记录
android·vue
zh_xuan1 天前
kotlin 挂起函数
android·开发语言·kotlin
贤泽1 天前
Android 15 Lock Task 模式深度分析(第一部分)
android
zh_xuan1 天前
kotlin launch函数
android·kotlin·协程·launch
贤泽1 天前
android 15 AOSP Broadcast 广播机制源码分析
android·aosp
啥都想学点1 天前
第1天:搭建 flutter 和 Android 环境
android·flutter
huohuopro1 天前
Android WebView 输入法同步问题解决方案
android