gpt4 book ai didi

android - 调用需要 API 级别 16(当前最小值为 14) : android. app.Notification.Builder#build

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

enter image description here文档说 Notification.Builder 是在 API 级别 11 中添加的。为什么我会收到此 lint 错误?

Call requires API level 16 (current min is 14): android.app.Notification.Builder#build

notification = new Notification.Builder(ctx)
.setContentTitle("Title").setContentText("Text")
.setSmallIcon(R.drawable.ic_launcher).build();

list :

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />

我错过了什么吗?

如果我错了,请纠正我,但 API 是在第 11 级添加的,对吗​​? Added in API level 11

最佳答案

NotificationBuilder.build()需要 API 级别 16 或更高。 API 级别 11 和 15 之间的任何内容都应使用 NotificationBuilder.getNotification() .所以使用

notification = new Notification.Builder(ctx)
.setContentTitle("Title").setContentText("Text")
.setSmallIcon(R.drawable.ic_launcher).getNotification();

关于android - 调用需要 API 级别 16(当前最小值为 14) : android. app.Notification.Builder#build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16445805/

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