Skip to content

Instantly share code, notes, and snippets.

@wiyarmir
Forked from ferrannp/locale-android.java
Last active September 13, 2017 10:58
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 wiyarmir/008a8f5e0db62eba43f9f3cf601e5b09 to your computer and use it in GitHub Desktop.
Save wiyarmir/008a8f5e0db62eba43f9f3cf601e5b09 to your computer and use it in GitHub Desktop.
private String currentLocale;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
currentLocale = getResources().getConfiguration().locale.toString();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
String newLocale = newConfig.locale.toString();
if (currentLocale.equals(newLocale)) {
return;
}
currentLocale = newLocale;
final ReactInstanceManager instanceManager = getReactInstanceManager();
instanceManager.recreateReactContextInBackground();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment