Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// when i m updating language so its continously launching activity ... how will i resolve this issue ?
private void updateLanguageBasedOnLocalStorage() {
languageSelection = SharedPreferencesManager.getSharedPreferenceInstance(context).getSharedPreferenceString(context, getString(R.string.str_language));
if (TextUtils.isEmpty(languageSelection)) {
languageSelection = getString(R.string.str_en);
}
setLocal(languageSelection);
}
public void setLocal(String lang) {
local = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = local;
res.updateConfiguration(conf, dm);
setAllFieldsEmpty();
SharedPreferencesManager.getSharedPreferenceInstance(context).setBoolean(context, getString(R.string.str_language_applied), true);
finish();
Intent myIntent = new Intent(LoginActivity.this, LoginActivity.class);
startActivity(myIntent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.