Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Locale;

import android.app.Activity;

import android.content.res.Resources;

import android.util.DisplayMetrics;

public class Main {
    /**
     * Set default language
     * 
     * @param act
     * @param defLanguage
     */
    public static void setDefaultLanguage(Activity act, String defLanguage) {
        if (defLanguage != null) {
            // Change locale settings in the app.
            Resources res = act.getResources();
            DisplayMetrics dm = res.getDisplayMetrics();
            android.content.res.Configuration conf = res.getConfiguration();
            conf.locale = new Locale(defLanguage);
            res.updateConfiguration(conf, dm);
        }
    }
}