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.content.Context;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.DisplayMetrics;

public class Main {
    public static void setLocale(Context paramContext, Locale paramLocale) {
        Resources localResources = paramContext.getResources();
        Configuration localConfiguration = localResources.getConfiguration();
        if (localConfiguration.locale.equals(paramLocale)) {

        } else {
            DisplayMetrics localDisplayMetrics = localResources.getDisplayMetrics();
            localConfiguration.locale = paramLocale;
            localResources.updateConfiguration(localConfiguration, localDisplayMetrics);
            Resources.getSystem().updateConfiguration(localConfiguration, localDisplayMetrics);
        }
    }
}