根据mac地址+deviceid获取设备唯一编码 获取手机及SIM卡相关信息

时间:2022-06-02 19:02:06

根据mac地址+deviceid获取设备唯一编码:

private static String DEVICEKEY = "";

/**
* 根据mac地址+deviceid
* 获取设备唯一编码
* @return
*/
public static String getDeviceKey()
{
if ("".equals(DEVICEKEY))
{
String macAddress = "";
WifiManager wifiMgr = (WifiManager)MainApplication.getIns().getSystemService(MainApplication.WIFI_SERVICE);
WifiInfo info = (null == wifiMgr ? null : wifiMgr.getConnectionInfo());
if (null != info)
{
macAddress = info.getMacAddress();
}
TelephonyManager telephonyManager =
(TelephonyManager)MainApplication.getIns().getSystemService(MainApplication.TELEPHONY_SERVICE);
String deviceId = telephonyManager.getDeviceId();
DEVICEKEY = MD5Util.toMD5("android" + Constant.APPKEY + Constant.APPPWD + macAddress + deviceId);
}
return DEVICEKEY;
}


获取手机及SIM卡相关信息:

/**
* 获取手机及SIM卡相关信息
* @param context
* @return
*/
public static Map<String, String> getPhoneInfo(Context context) {
Map<String, String> map = new HashMap<String, String>();
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
String imsi = tm.getSubscriberId();
String phoneMode = android.os.Build.MODEL;
String phoneSDk = android.os.Build.VERSION.RELEASE;
map.put("imei", imei);
map.put("imsi", imsi);
map.put("phoneMode", phoneMode+"##"+phoneSDk);
map.put("model", phoneMode);
map.put("sdk", phoneSDk);
return map;
}