Android所有的设备都可以返回一个TelephonyManager.getDeviceId(),但会暴露DeviceID,最好把这些id加密。加密后的序号仍然可以唯一的识别该设备。
例如,使用 String.hashCode() ,结合UUID:
获取唯一机器码
final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
这篇文档对您是否有帮助?