需求
通知栏显示过多通知,有的是前台服务,客户反馈有的前台服务点不进去,不想让它出现在通知栏.
所以让其在添加显示时过滤掉即可。
修改
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