【问题标题】:Notification.bigContentView is deprecated in API 24 (Nougat) what is the alternative?API 24 (Nougat) 中不推荐使用 Notification.bigContentView 有什么替代方案?
【发布时间】:2016-08-28 08:12:54
【问题描述】:

我刚刚将 compile sdk 版本从 API 23 升级到 API 24,看来 Notification.bigContentView 已被弃用。

那么问题来了,在 API 24 中设置 bigContentView 在 Android API 24(Nougat) 中的等效方法是什么?

【问题讨论】:

  • 关于Notification的所有消息可以参考android官方文档here,希望对你有所帮助
  • @AbAppletic 请更新我在答案中添加的链接,它正好指向您应该看到的位置
  • 我知道您知道该链接,但是它将对未来的用户有用:)
  • @AbAppletic 好的,如果它会有所帮助,那很好
  • @AbAppletic 你的问题解决了吗stackoverflow.com/questions/39148858/…

标签: android android-7.0-nougat


【解决方案1】:

NotificationBuilderCompat 有一个新方法setCustomBigContentView() 在 v4 支持库中 24.

您可以使用此方法来避免弃用警告,并且该方法向后兼容。

引用文档:

从 N 开始,该字段可能为空。扩展的通知视图由Notification.Builder 的输入决定;可以选择使用setCustomBigContentView(RemoteViews) 提供自定义 RemoteViews。

https://developer.android.com/reference/android/app/Notification.html#bigContentView

【讨论】:

  • 谢谢,这有帮助!
猜你喜欢
  • 2022-09-25
  • 2012-03-03
  • 2018-03-21
  • 2021-03-28
  • 2021-04-26
  • 2021-10-29
  • 2021-10-23
  • 1970-01-01
  • 2019-03-19
相关资源
最近更新 更多