首页 > 解决方案 > Kotlin 中未解决的参考“设置”

问题描述

我正在尝试使用putInt在 System Settings 属性中写入一些值,但出现错误。编译器说“未解决的参考设置”。请检查以下代码 -

Settings.System.putInt(context.contentResolver, SETTINGS_1, shutterOpen)
Settings.System.putInt(context.contentResolver, SETTINGS_2, muted)

有人可以帮忙吗?我是否必须导入任何额外的东西才能使用此功能?我是 Kotlin 的新手,由于资源限制,我很难修复它。

标签: androidkotlin

解决方案


你必须import android.provider.Settings;

提示:在 Android Studio 中,等待自动完成出现然后按 Tab 或 Enter。所需的包将自动导入。

在此处输入图像描述


推荐阅读