Skip to content Skip to sidebar Skip to footer

Onconfigurationchange Not Called After Changing Locale

I have to refresh the fragments contents on change of language from one fragment. So I thought of using onConfigurationChange method which is in my Main activity (this activity con

Solution 1:

You can extend from Application and set it in the manifest. Then, put onConfigurationChanged there, and check if the previous locale is the same as the current one:

if(!_currentLocale.equals(newConfig.locale))
  {
  _currentLocale=newConfig.locale;
  // locale has changed
  }

The "_currentLocale" variable should be initialized on the onCreate method of the new class (that extends Application), as such:

@OverridepublicvoidonCreate()
    {
    super.onCreate();
    _currentLocale=getResources().getConfiguration().locale;
    }

Solution 2:

Use layoutDirection attribute in the manifest file.

Post a Comment for "Onconfigurationchange Not Called After Changing Locale"