Skip to content

Instantly share code, notes, and snippets.

@engr-erum
Created November 29, 2017 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engr-erum/3e15ae11f98ddee740a517aad1cfa1f9 to your computer and use it in GitHub Desktop.
Save engr-erum/3e15ae11f98ddee740a517aad1cfa1f9 to your computer and use it in GitHub Desktop.
// 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