【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
相关推荐
安卓理事人3 小时前
安卓LinkedBlockingQueue消息队列
android
万能的小裴同学4 小时前
Android M3U8视频播放器
android·音视频
q***57745 小时前
MySql的慢查询(慢日志)
android·mysql·adb
JavaNoober5 小时前
Android 前台服务 "Bad Notification" 崩溃机制分析文档
android
城东米粉儿6 小时前
关于ObjectAnimator
android
zhangphil7 小时前
Android渲染线程Render Thread的RenderNode与DisplayList,引用Bitmap及Open GL纹理上传GPU
android
火柴就是我8 小时前
从头写一个自己的app
android·前端·flutter
lichong9519 小时前
XLog debug 开启打印日志,release 关闭打印日志
android·java·前端
用户69371750013849 小时前
14.Kotlin 类:类的形态(一):抽象类 (Abstract Class)
android·后端·kotlin
火柴就是我9 小时前
NekoBoxForAndroid 编译libcore.aar
android