gpt4 book ai didi

android - 通知 channel 的重要性是否会被个别通知的重要性所覆盖?

转载 作者:太空狗 更新时间:2023-10-29 16:26:22 25 4
gpt4 key购买 nike

问题是针对 Android O 及更高版本的。

例如,我创建了一个名为“default”的通知 channel 并将其设置为IMPORTANCE_DEFAULT。然后我创建了一个通知,将其添加到 channel 并将 IMPORTANCE_HIGH 放入其构建器中。通知的最终优先级是什么?

我没有在文档中找到答案,他们说需要个别的才能支持旧版本:

To support devices running Android 7.1 (API level 25) or lower, you must also call setPriority() for each notification, using a priority constant from the NotificationCompat class.

https://developer.android.com/training/notify-user/channels#importance

最佳答案

根据我的经验,在 Android O 及更高版本上,NotificationChannel 的重要性似乎优先于各个通知的优先级。

在我自己的应用程序中,我手动指定每个通知的优先级,以符合您引用的 Google 的建议。我只是尝试将通知的优先级设置为 PRIORITY_MAX 并通过重要性为 IMPORTANCE_DEFAULT 的 NotificationChannel 将其发送出去,并且通知出现在状态栏中而没有向下滑动(就像单挑显示)就像您使用带有 IMPORTANCE_HIGH 的 NotificationChannel 时的情况。

关于android - 通知 channel 的重要性是否会被个别通知的重要性所覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51087353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com