Android Context Set setDefaultLocale(Context context, String locale)

Here you can find the source of setDefaultLocale(Context context, String locale)

Description

Change the default locale of the application for this activity

License

Open Source License

Parameter

Parameter Description
locale To set in the configuration

Declaration

public static void setDefaultLocale(Context context, String locale) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.content.res.Configuration;

import java.util.Locale;

public class Main {
    /**//from   ww  w  . ja v  a  2  s  .  c o  m
     * Change the default locale of the application for this activity
     *
     * @param locale
     *    To set in the configuration
     */
    public static void setDefaultLocale(Context context, String locale) {
        Locale locJa = new Locale(locale);
        Locale.setDefault(locJa);

        Configuration config = new Configuration();
        config.locale = locJa;

        if (context != null) {
            context.getResources().updateConfiguration(config,
                    context.getResources().getDisplayMetrics());
        }
    }
}

Related

  1. sendSms(@Nonnull Context context, @CheckForNull String number, @Nullable String text)
  2. sendStopKey(Context c)
  3. setAppContext(Context context)
  4. setBaiduServiceEnabled(Context paramContext, boolean paramBoolean)
  5. setContext(Application app)
  6. setLanguage(Context context, String language)
  7. setProxy(Context ctx)
  8. setProxy(Context ctx, String host, int port)
  9. setRevokedPermissions(String packageName, String[] permissions, Context ctx)