-1

i'm working on application that supports multiple languages and i want to make my application language away of os language so scenario happened to me

i selected english language from my app settings and every thing is localized pretty good next i put my app in background then switched os languages to french then tried to resume my application and i found french string resources appears and if i killed the application and opened it again it will show my setting original language as i selected so can anyone help ne

user101530
  • 87
  • 12

1 Answers1

0

You need something like the following method to change the users locale:

public void setLocale(String lang) {
    myLocale = new Locale(lang);
    Resources res = getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
    Intent refresh = new Intent(this, AndroidLocalize.class);
    startActivity(refresh);
}

This should do the trick. The locale for english for example is: 'en' or for german it is 'de'.

Deutro
  • 3,113
  • 4
  • 18
  • 26
  • this is not the state that i'm talking about, i can change my localization from my app settings freely but if the i changed os language it affects my application too – user101530 Mar 05 '15 at 16:34
  • Ah okay, sry I missunderstood your question. – Deutro Mar 06 '15 at 07:06