android - 在不使用 @SuppressWarnings 的情况下解决 lint 已弃用的警告
问题描述
我有一种感觉,我可以在不强行压制它的情况下处理上述警告。但是,这似乎不起作用:
static Context updateResources(Context context) {
Resources resources = context.getResources();
Configuration config = new Configuration(resources.getConfiguration());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String lang = preferences.getString(Constants.PREF_KEY_LOCALE_OVERRIDE, Constants.PREF_VALUE_LOCALE_SYSTEM);
Locale locale = new Locale(lang);
if (Build.VERSION.SDK_INT >= 17) {
config.setLocale(locale);
context = context.createConfigurationContext(config);
} else {
//this is where the warning is at:
config.locale = locale;
resources.updateConfiguration(config, null);
}
return context;
}
如何清除此警告?
警告:配置中的 [deprecation] 语言环境已被弃用
config.locale = 语言环境;
解决方案
推荐阅读
- bootstrap-4 - 不是更新所有 Bootstrap 网格断点
- java - Java(Android)文件对象对于 AsyncTask 来说太慢了
- css - 如何删除嵌入在网站上的订阅按钮中的文本
- python - Python 错误:TypeError:'Timestamp' 类型的对象不是 JSON 可序列化的'
- java - 在 PostgreSQL JDBC 中设置模式似乎不起作用
- php - 如何使用 Laravel 在网站中实现 OCR
- macos - 如何从可执行文件更改mac应用程序名称?
- java - 尝试根据字符串数组列表的索引来累加双数组列表的总成本
- javascript - 如何将html文件的控制台输出带入phantomjs
- hazelcast - Hazelcast 分区队列