添加工具类SystemUtil :
public class SystemUtil {/*** 获取当前手机系统语言。* 例如:当前设置的是“中文-中国”,则返回“zh-CN”*/public static String getSystemLanguage() {return Locale.getDefault().getLanguage();}/*** 获取当前系统上的语言列表(Locale列表)*/public static Locale[] getSystemLanguageList() {return Locale.getAvailableLocales();}/*** 获取当前手机系统版本号*/public static String getSystemVersion() {return android.os.Build.VERSION.RELEASE;}/*** 获取手机型号*/public static String getSystemModel() {return android.os.Build.MODEL;}/*** 获取手机厂商*/public static String getDeviceBrand() {return android.os.Build.BRAND;}/*** 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)*/@SuppressLint("MissingPermission")public static String getIMEI(Context ctx) {TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);if (tm != null) {return tm.getDeviceId();}return null;}}
添加权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
在 activity 中添加方法:
private void getPhone() {Log.e("=====", "手机厂商:" + SystemUtil.getDeviceBrand());Log.e("=====", "手机型号:" + SystemUtil.getSystemModel());Log.e("=====", "手机当前系统语言:" + SystemUtil.getSystemLanguage());Log.e("=====", "Android系统版本号:" + SystemUtil.getSystemVersion());Log.e("=====", "手机IMEI:" + SystemUtil.getIMEI(getApplicationContext()));}
这样就可以查看手机的信息了: