获取系统语言(兼容7.0)- https://blog.youkuaiyun.com/ys743276112/article/details/71547134
在 Android 7.0 上:getResources().getConfiguration().locale 被标记为 deprecated 了,所以初步适配后是:
Locale locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
locale = getResources().getConfiguration().getLocales().get(0);
} else {
locale = getResources().getConfiguration().locale;
}
//或者仅仅使用 locale = Locale.getDefault(); 不需要考虑接口 deprecated(弃用)问题
String lang = locale.getLanguage() + "-" + locale.getCountry();
Android获取系统语言
最新推荐文章于 2023-05-25 16:02:42 发布
本文介绍了一种在Android7.0及其以上版本中获取系统语言的方法,考虑到getResources().getConfiguration().locale已被弃用,文章提供了兼容新旧版本的代码实现。

2462

被折叠的 条评论
为什么被折叠?



