Android获取UUID(可变+不变)

xiaoxiao2021-02-28  9

1、UUID+设备号序列号 唯一识别码(不可变)

public static String getDevUUID(Context mContext) { synchronized (DevInfo.class) { if (uniqueId == null) { final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, tmPhone, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(mContext.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); uniqueId = deviceUuid.toString(); } } return uniqueId; }2、 Java  获取可变UUID

UUID uuid = UUID.randomUUID(); String uniqueId = uuid.toString();

转载请注明原文地址: https://www.6miu.com/read-450194.html

最新回复(0)