在Android 5.0中更改应用程序语言不起作用

Ahm*_*idi 6 android locale android-context

我正在使用下面的代码在按钮点击时更改我的应用程序语言(例如从法语更改为英语),它在Android 4.0 +上工作正常但在5.0上却没有.

Locale localeEn = new Locale("en_US");
Locale.setDefault(localeEn);
Configuration configEn = new Configuration();
configEn.locale = localeEn;
getApplicationContext().getResources().updateConfiguration(configEn, null);
this.recreate();
Run Code Online (Sandbox Code Playgroud)

有什么线索为什么好吗?

编辑:这是我的清单(使用android:configChanges)

<activity
            android:name=".activities.LoginActivity"
            android:configChanges="orientation|locale"
            android:label="@string/app_name"
            android:screenOrientation="portrait"/>
Run Code Online (Sandbox Code Playgroud)

Jor*_*ego 10

试着改变这个:

Locale localeEn = new Locale("en_US");
Locale.setDefault(localeEn);
Run Code Online (Sandbox Code Playgroud)

对此

String language = "en";
String country = "US";
Locale locale = new Locale(language , country);
Run Code Online (Sandbox Code Playgroud)