更新 DeviceInfoUtils.java
parent
7cc38536f0
commit
4ef4f6fe39
|
|
@ -1,12 +1,10 @@
|
||||||
package com.nbee.echolink.utils;
|
package com.nbee.echolink.utils;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
public class DeviceInfoUtils {
|
public class DeviceInfoUtils {
|
||||||
/**
|
/**
|
||||||
* 获取设备宽度(px)
|
* 获取设备宽度(px)
|
||||||
|
|
@ -15,111 +13,127 @@ public class DeviceInfoUtils {
|
||||||
public static int getDeviceWidth(Context context) {
|
public static int getDeviceWidth(Context context) {
|
||||||
return context.getResources().getDisplayMetrics().widthPixels;
|
return context.getResources().getDisplayMetrics().widthPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备高度(px)
|
* 获取设备高度(px)
|
||||||
*/
|
*/
|
||||||
public static int getDeviceHeight(Context context) {
|
public static int getDeviceHeight(Context context) {
|
||||||
return context.getResources().getDisplayMetrics().heightPixels;
|
return context.getResources().getDisplayMetrics().heightPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备的唯一标识, 需要 “android.permission.READ_Phone_STATE”权限
|
* 获取设备的唯一标识, 需要 “android.permission.READ_Phone_STATE”权限
|
||||||
* Android 10 无法获取此权限
|
* Android 10 无法获取此权限
|
||||||
*/
|
*/
|
||||||
// public static String getIMEI(Context context) {
|
public static String getIMEI(Context context) {
|
||||||
// TelephonyManager tm = (TelephonyManager) context
|
TelephonyManager tm = (TelephonyManager) context
|
||||||
// .getSystemService(Context.TELEPHONY_SERVICE);
|
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
// String deviceId = tm.getDeviceId();
|
String deviceId = tm.getDeviceId();
|
||||||
// if (deviceId == null) {
|
if (deviceId == null) {
|
||||||
// return "UnKnown";
|
return "UnKnown";
|
||||||
// } else {
|
} else {
|
||||||
// return deviceId;
|
return deviceId;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取厂商名
|
* 获取厂商名
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceManufacturer() {
|
public static String getDeviceManufacturer() {
|
||||||
return android.os.Build.MANUFACTURER;
|
return android.os.Build.MANUFACTURER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品名
|
* 获取产品名
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceProduct() {
|
public static String getDeviceProduct() {
|
||||||
return android.os.Build.PRODUCT;
|
return android.os.Build.PRODUCT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机品牌
|
* 获取手机品牌
|
||||||
*/
|
*/
|
||||||
public static String getDeviceBrand() {
|
public static String getDeviceBrand() {
|
||||||
return android.os.Build.BRAND;
|
return android.os.Build.BRAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机型号
|
* 获取手机型号
|
||||||
*/
|
*/
|
||||||
public static String getDeviceModel() {
|
public static String getDeviceModel() {
|
||||||
return android.os.Build.MODEL;
|
return android.os.Build.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机主板名
|
* 获取手机主板名
|
||||||
*/
|
*/
|
||||||
public static String getDeviceBoard() {
|
public static String getDeviceBoard() {
|
||||||
return android.os.Build.BOARD;
|
return android.os.Build.BOARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备名
|
* 设备名
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceDevice() {
|
public static String getDeviceDevice() {
|
||||||
return android.os.Build.DEVICE;
|
return android.os.Build.DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* fingerprit 信息
|
* fingerprit 信息
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceFubgerprint() {
|
public static String getDeviceFubgerprint() {
|
||||||
return android.os.Build.FINGERPRINT;
|
return android.os.Build.FINGERPRINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 硬件名
|
* 硬件名
|
||||||
*
|
*
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceHardware() {
|
public static String getDeviceHardware() {
|
||||||
return android.os.Build.HARDWARE;
|
return android.os.Build.HARDWARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主机
|
* 主机
|
||||||
*
|
*
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceHost() {
|
public static String getDeviceHost() {
|
||||||
return android.os.Build.HOST;
|
return android.os.Build.HOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 显示ID
|
* 显示ID
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceDisplay() {
|
public static String getDeviceDisplay() {
|
||||||
return android.os.Build.DISPLAY;
|
return android.os.Build.DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID
|
* ID
|
||||||
*
|
*
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceId() {
|
public static String getDeviceId() {
|
||||||
return android.os.Build.ID;
|
return android.os.Build.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机用户名
|
* 获取手机用户名
|
||||||
*
|
*
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceUser() {
|
public static String getDeviceUser() {
|
||||||
return android.os.Build.USER;
|
return android.os.Build.USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机 硬件序列号
|
* 获取手机 硬件序列号
|
||||||
* **/
|
**/
|
||||||
public static String getDeviceSerial() {
|
public static String getDeviceSerial() {
|
||||||
return android.os.Build.SERIAL;
|
return android.os.Build.SERIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机Android 系统SDK
|
* 获取手机Android 系统SDK
|
||||||
*
|
*
|
||||||
|
|
@ -128,6 +142,7 @@ public class DeviceInfoUtils {
|
||||||
public static int getDeviceSDK() {
|
public static int getDeviceSDK() {
|
||||||
return android.os.Build.VERSION.SDK_INT;
|
return android.os.Build.VERSION.SDK_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取手机Android 版本
|
* 获取手机Android 版本
|
||||||
*
|
*
|
||||||
|
|
@ -136,12 +151,14 @@ public class DeviceInfoUtils {
|
||||||
public static String getDeviceAndroidVersion() {
|
public static String getDeviceAndroidVersion() {
|
||||||
return android.os.Build.VERSION.RELEASE;
|
return android.os.Build.VERSION.RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前手机系统语言。
|
* 获取当前手机系统语言。
|
||||||
*/
|
*/
|
||||||
public static String getDeviceDefaultLanguage() {
|
public static String getDeviceDefaultLanguage() {
|
||||||
return Locale.getDefault().getLanguage();
|
return Locale.getDefault().getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前系统上的语言列表(Locale列表)
|
* 获取当前系统上的语言列表(Locale列表)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue