d468fcd78cd90fc874e69a233829af83b7f66ee6.svn-base 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package eVVM.apk.helper;
  2. import android.annotation.SuppressLint;
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.telephony.TelephonyManager;
  6. import java.util.Locale;
  7. /**
  8. * Created by Android Studio.
  9. * User: zbb
  10. * Date: 2019/6/3
  11. * Describe: SystemUtil 获取系统信息工具类
  12. */
  13. public class SystemUtil {
  14. /**
  15. * 获取当前手机系统语言。
  16. *
  17. * @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
  18. */
  19. public static String getSystemLanguage() {
  20. return Locale.getDefault().getLanguage();
  21. }
  22. /**
  23. * 获取当前系统上的语言列表(Locale列表)
  24. *
  25. * @return 语言列表
  26. */
  27. public static Locale[] getSystemLanguageList() {
  28. return Locale.getAvailableLocales();
  29. }
  30. /**
  31. * 获取当前手机系统版本号
  32. *
  33. * @return 系统版本号
  34. */
  35. public static String getSystemVersion() {
  36. return android.os.Build.VERSION.RELEASE;
  37. }
  38. /**
  39. * 获取手机型号
  40. *
  41. * @return 手机型号
  42. */
  43. public static String getSystemModel() {
  44. return android.os.Build.MODEL;
  45. }
  46. /**
  47. * 获取手机厂商
  48. *
  49. * @return 手机厂商
  50. */
  51. public static String getDeviceBrand() {
  52. return android.os.Build.BRAND;
  53. }
  54. /**
  55. * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)
  56. *
  57. * @return 手机IMEI
  58. */
  59. @SuppressLint("MissingPermission")
  60. public static String getIMEI(Context ctx) {
  61. TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
  62. if (tm != null) {
  63. return tm.getDeviceId();
  64. }
  65. return null;
  66. }
  67. }