I’m working multi languages on android 2.2. I change language in onCreate of every activities like this:
Locale locale = new Locale("nl");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());
Of course i put these code before calling setContentView and adding android:configChanges=”locale” into manifest. But when the launcher activity displayed at the first time there are some words change to my desired language correctly but some words stay in English. The other activities (not launcher activity) changed language is OK. And when i switch back to launcher activity from the other activities, it now changed all words to my desired language correctly. I don’t know why the first time of launcher there are some words in launcher activity not change to my desired language correctly.
Thanks for your help.
At last i found a solution that solved my problem completely. I figured out that the locale is reset automatically by system (or whatever has an ability of changing locale), that why i set the default locale but it worked not correctly. Here is my solution, you should create a class that extend Application, then override the method as below:
So every time the default locale is reset out side of your app, this method is called and it will reset default locale again with your desired language. Now it works pretty well.