get System Language - Android android.content

Android examples for android.content:Context

Description

get System Language

Demo Code

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import java.util.Locale;

public class Main{

    public static String getSystemLanguage(Context context) {
        if (null == context) {
            return null;
        }//from   w  ww .j  a v a 2s.c o  m

        Locale locale = null;
        try {
            locale = context.getResources().getConfiguration().locale;
        } catch (Exception e) {
            return null;
        }

        if (null != locale) {
            return locale.getLanguage();
        }
        return null;
    }

}

Related Tutorials