im using this and its not working, i have a preference activity and i have a listpreference to change between languages. It works but only when i navigate to anoter activity through the startActivity method. If i go back with the back arrow button they still show the old language.
This is the preferenceActivity:
public class Settings extends PreferenceActivity{
final static int PORTUGUESE=1;
final static int ENGLISH=2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
Preference langPref=(Preference)findPreference("listPref");
langPref.setOnPreferenceChangeListener(
new OnPreferenceChangeListener(){
@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {
String lanfpref=(String) newValue;
int lang=Integer.parseInt(lanfpref);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
switch(lang){
case PORTUGUESE:
conf.locale = Locale.ITALY;
break;
case ENGLISH:
conf.locale = Locale.ENGLISH;
break;
}
res.updateConfiguration(conf, dm);
return true;
}
});
}
}
The method onConfigurationChaged is on the other activity that calls this settings class.