我正在开发一个社交媒体应用程序,我希望为注册到我的服务器的每个设备生成唯一的编号。我的问题是,如何生成udid,以确保未来不会更改。
例如,如果用户卸载应用程序然后重新安装它(激活了udid生成),则其udid必须与卸载之前相同。此外,udid必须采用以下格式:
c376e418-da42-39fb-0000-d821f1fd2804
请分享任何想法!
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId;
if (telephonyManager.getDeviceId() != null)
deviceId = telephonyManager.getDeviceId(); //*** use for mobiles
else {
deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
}
return deviceId;