Example usage for android.content.res Configuration setLocales

List of usage examples for android.content.res Configuration setLocales

Introduction

In this page you can find the example usage for android.content.res Configuration setLocales.

Prototype

public void setLocales(@Nullable LocaleList locales) 

Source Link

Document

Set the locale list.

Usage

From source file:ca.appvelopers.mcgillmobile.ui.BaseActivity.java

/**
 * Updates the locale/*  w  w w  .  j  a  v a  2  s. co m*/
 */
private void updateLocale() {
    Locale locale = new Locale(languagePref.get());
    Configuration config = getBaseContext().getResources().getConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        config.setLocales(new LocaleList(locale));
    } else {
        //noinspection deprecation
        config.locale = locale;
    }
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());
}