无法以编程方式使用Android 8.0.0更改Google Pixel中的区域设置

时间:2017-09-28 15:35:18

标签: android

我需要将我的应用程序语言从英语更改为中文。我可以在许多设备中执行此操作,但Google Pixel除了安装了Android 8.0.0之外。 我正在使用以下代码

public static void changeLocaleTo(String locale){

            Resources res = App.getContext().getResources();
            DisplayMetrics dm = res.getDisplayMetrics();
            android.content.res.Configuration conf = res.getConfiguration();
            conf.setLocale(new Locale(locale.toLowerCase())); // API 17+ only.
            conf.locale = (new Locale(locale.toLowerCase()));
            res.updateConfiguration(conf, dm);
            //for Build>=25
            //res.createConfiguration(conf, dm); 
}

我使用以下链接尝试了很多东西

How to programmatically change language?

https://gunhansancar.com/change-language-programmatically-in-android/

但没有人能够更改我的Pixel手机中的语言。

请注意:但是,如果我从设备设置更改设备语言,我的应用也会更改为Pixel中的中文版。

我在res中有'values-zh'文件夹,中文字符串。

0 个答案:

没有答案