/**
* 获取当前设置的电话号码
*/
public static String getNativePhoneNumber(Context context) {
String nativePhoneNumber =
"";
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.
TELEPHONY_SERVICE);
nativePhoneNumber = telephonyManager.getLine1Number();
}
catch (Exception e) {
nativePhoneNumber =
"";
}
return nativePhoneNumber;
}
/**
* 获取设备序列号
*/
public static String getDeviceId(Context context) {
String deviceId =
"";
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.
TELEPHONY_SERVICE);
deviceId = telephonyManager.getDeviceId();
if (deviceId ==
null ||
"".equals(deviceId)) {
deviceId =
"0000000000";
}
return deviceId;
}
/**
* @description:获取设备唯一标识
*/
public static String getDeviceUni(Context context) {
String deviceUni =
"";
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.
TELEPHONY_SERVICE);
deviceUni = tm.getDeviceId();
if (TextUtils.
isEmpty(deviceUni)) {
deviceUni =
getMacAddress(context);
}
return deviceUni;
}
/**
* @description:获取wifimac地址
*/
public static String getMacAddress(Context context) {
WifiManager wifi = (WifiManager) context.getSystemService(Context.
WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
String wifiMac = info.getMacAddress();
return wifiMac;
}
转载请注明原文地址: https://ju.6miu.com/read-22564.html