gpt4 book ai didi

android - v4.app.NotificationCompat 和 v7.app.NotificationCompat 有什么区别?

转载 作者:IT老高 更新时间:2023-10-28 21:52:29 25 4
gpt4 key购买 nike

我正在阅读关于 google official website for building Notification 的教程

在实现代码时,我注意到 NotificationCompat 存在于 Support Libraries V4 和 V7 中。

它们之间有什么区别?

它们中的任何一个是否有助于将通知推送到锁定屏幕?

最佳答案

请注意,v7 NotificationCompat 在 API 级别 26 中已弃用,并且 v4 进行了一些扩展。如果你的 compileSdk 是 26+,你必须使用 v4。


正如您在 the docs 中看到的那样, v7 继承自 v4,然后添加了更多功能。

android.support.v7.app.NotificationCompat

An extension of NotificationCompat which supports NotificationCompat.MediaStyle. You should start using this variant if you need support for media styled notifications.

v7 可以做 v4 可以做的一切。唯一不同的是v7也支持.MediaStyle,而v4不支持。

关于锁定屏幕,有一些常量定义了它们的工作方式,例如是否显示:

VISIBILITY_PRIVATE , VISIBILITY_PUBLICVISIBILITY_SECRET

关于android - v4.app.NotificationCompat 和 v7.app.NotificationCompat 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33209501/

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