A task consists of the following: it is needed to give possibility of change of language of interface of application (ru, en, uk, well and on a default will be chosen en) to the user. For realization of this functional it was done:
1) the folders of resources were created: values, values - uk, values - ru, values - en, where the files strings.xml with content translation.
2) by means of Spinner gets out and written down in SharedPreferences language id.
3) At the start of application in onCreate localization is used :
SharedPreferences preferences = context.getSharedPreferences(Constants.APP_PREFERENCES, Context.MODE_PRIVATE);
String lang = preferences.getString(Constants.LANGUAGE, "default");
if (lang.equals("default")) {
lang=context.getResources().getConfiguration().locale.getCountry();
}
Locale locale = new Locale(lang);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
Log.i("Lang change", "Locale=" + locale);
context.getResources().updateConfiguration(config,
context.getResources().getDisplayMetrics());
Almost all pulls up and applies, but not all. Namely, in some places (in some dialogues and BaseAdapters, NavigationDrawer) pulls up localization exactly of language of the system. For example, on a device the Ukrainian localization, on a default is English, and the Russian is chosen in an app, then in the total in an app in the higher indicated places pulls up Ukrainian content besides basic Russian.
Broke through to process in onConfigurationChanged():
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
locale = new Locale(lang);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);
}
and cleaned from every activity in manifest.xml android: configChanges = "locale".
Did not help.
What can a problem be in?