1.kotlin版本
1 import java.util.*
2
3 class SystemUtil {
4
5 companion object{
6
7 @JvmStatic
8 fun getSystemLanguage() : String{
9 return Locale.getDefault().getLanguage()
10 }
11
12 @JvmStatic
13 fun getSystemLanguageList() : Array<Locale> {
14 return Locale.getAvailableLocales()
15 }
16
17 @JvmStatic
18 fun getSystemVersion() : String{
19 return android.os.Build.VERSION.RELEASE
20 }
21
22 @JvmStatic
23 fun getSystemModel() : String{
24 return android.os.Build.MODEL
25 }
26
27 @JvmStatic
28 fun getDeviceBrand() : String{
29 return android.os.Build.BRAND
30 }
31 }
32
33 }
2.java版本
1 package com.jiankangyangfan.nurse.util;
2
3 import java.util.Locale;
4
5 public class SystemUtil {
6
7 /**
8 * 获取当前手机系统语言。
9 *
10 * @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
11 */
12 public static String getSystemLanguage() {
13 return Locale.getDefault().getLanguage();
14 }
15
16 /**
17 * 获取当前系统上的语言列表(Locale列表)
18 *
19 * @return 语言列表
20 */
21 public static Locale[] getSystemLanguageList() {
22 return Locale.getAvailableLocales();
23 }
24
25 /**
26 * 获取当前手机系统版本号
27 *
28 * @return 系统版本号
29 */
30 public static String getSystemVersion() {
31 return android.os.Build.VERSION.RELEASE;
32 }
33
34 /**
35 * 获取手机型号
36 *
37 * @return 手机型号
38 */
39 public static String getSystemModel() {
40 return android.os.Build.MODEL;
41 }
42
43 /**
44 * 获取手机厂商
45 *
46 * @return 手机厂商
47 */
48 public static String getDeviceBrand() {
49 return android.os.Build.BRAND;
50 }
51
52 }