0

I use this code to change the locale of my app programatically:

Locale.setDefault(locale);
Configuration config = getBaseContext().getResources().getConfiguration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
       getBaseContext().getResources().getDisplayMetrics());
recreate();

Works like a charme for this activity and all activities afterwards, but if I use the back-function of my cellphone, the last activity is reused, with the old locale.

Any way to invalidate the last activity or to force recreate on it?

murkr
  • 634
  • 5
  • 27

1 Answers1

0

This post solved the problem: How to recreate previous activity?

My final solution is:

@Override
public void onResume() {
    super.onResume();
    if(!currentLanguage.equals(getResources().getConfiguration().locale.getLanguage())) {
        recreate();
    }
}

and in onCreate() :

currentLanguage = getResources().getConfiguration().locale.getLanguage();

(Should have searched more).

murkr
  • 634
  • 5
  • 27