【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
相关推荐
qq_452396237 小时前
第十篇:《自动化处理验证码:OCR、接口绕过与第三方服务》
android·自动化·ocr
a8a3028 小时前
Laravel 10.x核心特性深度解析
android
angerdream9 小时前
Android手把手编写儿童手机远程监控App之UUID
android
dalancon10 小时前
Android OomAdjuster流程
android
河婆墟邓紫棋10 小时前
MIUI中的权限
android·github
我命由我1234511 小时前
Java 开发 - CountDownLatch 不需要手动关闭
android·java·开发语言·jvm·kotlin·android studio·android-studio
众少成多积小致巨11 小时前
GNU Make 核心指南
android·c++
凛_Lin~~11 小时前
安卓进程保活方案记录(双重fork+文件锁+手搓parcel)
android·安卓
海天鹰12 小时前
安卓相机:获取最近拍摄的照片缩略图做相册按钮图标
android
tongyiixiaohuang12 小时前
技术案例分享:金蝶云星空客户数据同步到MySQL的实现
android·数据库·mysql