push-notification - android,如何找出通知属于哪个频道
问题描述
在 android 应用程序中,当有活动通知时,它可以使用
NotificationManager.getActiveNotifications()
获取活动通知。
如果应用配置了多个通知组和频道,如何找出活动通知属于哪个频道?
解决方案
StatusBarNotification[] list = notificationManager.getActiveNotifications();
for(int i=0;i<list.length;i++) {
StatusBarNotification activeNoti = list[i];
Notification noti = activeNoti.getNotification();
//to get channel ID
String channelId = noti.getChannelId();
}
注意: notificationManager.getActiveNotifications()
只会给出您的应用程序构建的通知(它不会返回不是您的应用程序构建的其他通知)
推荐阅读
- flutter - 为什么它在颤动中显示'方法'rootAncestorStateOfType'在null上被调用'?
- visual-studio-code - VSCode 扩展修改 files.exclude 配置
- c# - 隐式转换和显式转换是否具有相同的性能?
- r - 行规范化和列规范化的区别
- react-native - 贝宝 - 自动支付
- angular - 角材料芯片占位符浮动而不是在末端附着
- julia - Julia 中的准随机抽样
- python - 在带有反向引用的多行字符串中匹配python中的正则表达式的问题
- git - 在 go 项目中将 git 子模块保存在哪里?
- unity3d - 如何生成特定区域的地形