Я использую этот код для изменения локали приложения по умолчанию
Код: Выделить всё
private static Context updateResources(Context context, String language)
{
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration configuration = context.getResources().getConfiguration();
configuration.setLocale(locale);
return context.createConfigurationContext(configuration);
}
Код: Выделить всё
@Override
protected void attachBaseContext(Context newBase)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String language = preferences.getString(SELECTED_LANGUAGE, "fa");
super.attachBaseContext(updateResources(newBase, language));
}
Код: Выделить всё
getActivity().getBaseContext().getStringКод: Выделить всё
Также getActivity( )..getResources().getIdentifier не работает и всегда возвращает 0!
Подробнее здесь: https://stackoverflow.com/questions/552 ... o-androidx