I change the language at my own application settings. How can I directly load the new language in the settings activty.
I find out the solution to go too an other activity and than the language is changed. I want it earlier
The Code where I change the language:
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String language =SP.getString("language", "en");
android.content.res.Configuration config = new android.content.res.Configuration();
config.locale = new Locale(language);
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
my onConfigurationChanged Method:
@Override
public void onConfigurationChanged(Configuration locale) {
super.onConfigurationChanged(locale);
Toast.makeText(settings.this, "test", Toast.LENGTH_SHORT).show();
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String language =SP.getString("language", "en");
android.content.res.Configuration config = new android.content.res.Configuration();
config.locale = new Locale(language);
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());