Reputation: 1752
Actually I'm handling 3 languages in my app so I have:
values/strings.xml
values-it/strings.xml
values-de/strings.xml
When I install the app, it is properly installed in the current language of the device. But if I change the language of the device, the language of the app doesn't switch. I have to reinstall it to switch the language.
I've seent that this happens also to other apps, but not to all. The "big" ones (whatsapp, viber, all google's, etc) change.
So the question is: how can an app follow the device's language change ?
Upvotes: 2
Views: 1777
Reputation: 1752
I add an answer to help someone with the same problem. First thing to do to get an event that the language was changed, is to add this to the manifest:
<activity
....
android:configChanges="layoutDirection|locale"
....
</activity>
Please note the layoutDirection
: without it, it doesn't work! Only locale
does not trigger the event. It has something to do with right-to-left languages but I didn't investigate further.
Then, in the activity, add a:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
}
This is called when the app is resumed and the newConfig
contains all the informations needed, for example newConfig.locale.getLanguage()
How to then update the language in your app, is up to you but reading the documentation suggested by @StenSoft would be a good decision.
Upvotes: 2
Reputation: 6697
It should work without any problem unless you have android:configChanges="locale"
specified for your activity in your Androidmanifest file
Upvotes: 2