Skip to content

Instantly share code, notes, and snippets.

@ferrannp
Created September 11, 2017 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ferrannp/cb14fc0b7350b3ed8d3e338ba0f0b2cb to your computer and use it in GitHub Desktop.
Save ferrannp/cb14fc0b7350b3ed8d3e338ba0f0b2cb to your computer and use it in GitHub Desktop.
static String currentLocale;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivity.currentLocale = getResources().getConfiguration().locale.toString();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
String locale = newConfig.locale.toString();
if (!MainActivity.currentLocale.equals(locale)) {
MainActivity.currentLocale = locale;
final ReactInstanceManager instanceManager = getReactInstanceManager();
instanceManager.recreateReactContextInBackground();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment