【问题标题】:What are the differences between the two methods which both get Locale object两种获取Locale对象的方法有什么区别
【发布时间】:2013-10-24 11:09:49
【问题描述】:

在 android 中,我可以通过以下方式获取 Locale 实例:

Locale locale = getContext().getResources().getConfiguration().locale;

或通过:

Locale.getDefault().toString();

谁能具体解释一下这两者的区别

是不是一个用于应用程序级区域设置而另一个用于系统区域设置?

另一个问题:有没有办法以编程方式更改设备级别的语言环境? (非应用级区域设置

提前致谢。

【问题讨论】:

    标签: android android-layout android-intent android-listview


    【解决方案1】:

    来自android documentation for Locale

    您可以使用 getDefault() 为 user 的 您正在运行的设备

    Andr 来自android documentation for Configuration

    区域设置:当前用户对区域设置的偏好

    所以是的,.getConfiguration() 区域设置是基于应用程序的用户偏好,而 getDefault() 区域设置是(仍然是特定于用户的)设备级别选择。

    【讨论】:

    • 谢谢,顺便说一句,我知道如何更改应用级别的语言环境,但有没有办法以编程方式更改设备级别的语言环境?
    • 我不知道... 编辑 类似问题here
    猜你喜欢
    • 2013-09-08
    • 2019-03-31
    • 1970-01-01
    • 2018-04-20
    • 1970-01-01
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    相关资源
    最近更新 更多