Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Locale;

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

public class Main {
    /**
     * 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());
        }
    }
}