I'm using this code below to change my app language on button click (changing from french to english for example), it's works fine on android 4.0 + but on 5.0 it doesn't.
Locale localeEn = new Locale("en_US");
Locale.setDefault(localeEn);
Configuration configEn = new Configuration();
configEn.locale = localeEn;
getApplicationContext().getResources().updateConfiguration(configEn, null);
this.recreate();
Any clues why please?
edit : this is my manifest ( with android:configChanges )
<activity
android:name=".activities.LoginActivity"
android:configChanges="orientation|locale"
android:label="@string/app_name"
android:screenOrientation="portrait"/>
Try to change from this:
to this
My solution, that i got from Udhay, works when user changes the language in actionbar and app "refreshes" with selected language. I am using android 6.0.
There is no need to add locale to androidManifest.
My solution was changing the locale before activity's
Have you added
android:configChanges="locale"
inAndroidManifest.xml
? I think the problem is in yourAndroidManifest.xml
file.You can see example change locale on my github repository.