I’m a forcing a locale after option changes:
public void forceLocale(Context ctx) {
Locale.setDefault(getCurrentLocale());
Configuration config = new Configuration();
config.locale = getCurrentLocale();
ctx.getResources().updateConfiguration(config, ctx.getResources().getDisplayMetrics());
}
I’d like the current activity to be displayed in a new Locale, but it doesen’t happen. It’s the same for the other activities.
I tried invalidate on onResume() of all my activities:
protected void onResume() {
//if no custom locale, restore default
if (StaticClass.locale.getCurrentLocale() == null)
StaticClass.locale.restoreDefaultLocale();
//force curretnt locale
StaticClass.locale.forceLocale(this);
//reload the view
ViewGroup vg = (ViewGroup) findViewById(android.R.id.content);
vg.invalidate();
super.onResume();
}
No effect. The app gets translated after it gets wiped out from memory and restarted
Do you have the locale attribute set in your manifest
android:configChanges="locale"? I also added this to myonCreate()in each activityif (Globals.langConfig != null)this.onConfigurationChanged(Globals.langConfig);
then I override the
onConfigurationChanged()in each activityThis may not be the best way but has worked for me for now. If you don’t already, I think overriding the
onConfigurationChanged()method may be your biggest problem