After several attempts, I have found the solution to my problem. On my onCreate
method, I get the SharedPreferences
that contains the value of current language, and get the current language:
SharedPrefrences languagepref = getSharedPreferences("language",MODE_PRIVATE);
String language = languagepref.getString("languageToLoad", Locale.getDefault().getDisplayLanguage());
Then, in my onResume
method, I assign the value of the above mentioned variable language
to a local variable, and update the value of language
. Then I compare these two variables - if they are different, I will destroy the current activity and start another:
@Override
public void onResume(){
super.onResume();
String oldLanguage = language;
language = languagepref.getString("languageToLoad", Locale.getDefault().getDisplayLanguage());
if (!oldLanguage.equals(language)){
finish();
startActivity(getIntent());
}
}
And voila, that did the trick!