我需要一个对于每台设备都是唯一的 ID。此 ID 将存储在服务器中,并将用于识别设备。我正在考虑使用 IMEI 号码,但出于隐私原因我不想将 IMEI 号码发送到服务器。
所以,我正在考虑这样做
- Get IMEI number.
- Hash the IMEI number using SHA-1.
- Send this to server
这是获得唯一设备 ID 而无需担心隐私问题的可靠方法吗?请指教。
最佳答案
使用以下方法获取 IMEI 号码
String identifier = null;
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null)
identifier = tm.getDeviceId();
if (identifier == null || identifier .length() == 0)
identifier = Secure.getString(activity.getContentResolver(),Secure.ANDROID_ID);
并添加此权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
关于android - Android 设备的唯一 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17445217/