简体   繁体   English

Android:Android设备的唯一ID以标识唯一设备

[英]Android : Unique Id for android device to identify the unique device

I need an ID which will not change for android device and it should be unique at any time even if WIFI, SIM, Bluetooth are not present as well as when user reset his/her phone or flash with new OS. 我需要一个不会为Android设备更改的ID,即使没有WIFI,SIM卡,蓝牙以及用户重置手机或使用新的操作系统刷新时,ID也应在任何时候都是唯一的。

I know about these Id. 我知道这些ID。 IMEI : It is not available for all device(Ex. SIM less device). IMEI:并非适用于所有设备(例如不含SIM卡的设备)。

MAC : Is is not available for all device(Ex. WIFI less device). MAC:不适用于所有设备(例如,WIFI少设备)。

Android Id : It changed when user Reset his/her phone or device is root with new OS. Android ID:当用户将手机或设备重置为新操作系统的root用户时,它已更改。

Which will be better for my requirement? 哪个会更好地满足我的要求?

Should I used Serial Id. 我应该使用序列号吗? Build.SERIAL?? Build.SERIAL?

You could use a combination of manufacturer info, device name and serial. 您可以使用制造商信息,设备名称和序列号的组合。 This should be unique and available over all devices: 这应该是唯一的,并且可以在所有设备上使用:

StringBuilder sb = new StringBuilder();

sb.append(android.os.Build.MANUFACTURER);
sb.append(" ");
sb.append(android.os.Build.MODEL);
sb.append(" ");
sb.append(android.os.Build.SERIAL);

String unique = sb.toString();

Please check this link below right from android developers blog. 请在android开发者博客中查看下面的此链接。 http://android-developers.blogspot.in/2011/03/identifying-app-installations.html http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

Copying specific details from the link to answer your question. 从链接中复制特定详细信息以回答您的问题。

For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. 对于绝大多数应用程序,要求是确定特定的安装,而不是物理设备。 Fortunately, doing so is straightforward. 幸运的是,这样做很简单。

There are many good reasons for avoiding the attempt to identify a particular device. 有许多充分的理由可以避免尝试识别特定设备。 For those who want to try, the best approach is probably the use of ANDROID_ID on anything reasonably modern, with some fallback heuristics for legacy devices. 对于那些想尝试的人来说,最好的方法可能是在任何相当现代的东西上使用ANDROID_ID,并对旧式设备进行一些回退启发。

If your requirement is to uniquely identify each user generating UUID for each user and storing it on server would do. 如果您的要求是唯一地标识每个用户,则为每个用户生成UUID并将其存储在服务器上就可以了。 But if you really want to get physical device unique identifier, ANDORID_ID looks to be the only probable way. 但是,如果您真的想获取物理设备的唯一标识符,则ANDORID_ID似乎是唯一可能的方法。

Having said that, Please be aware of this bug (and how android_id is different for different profiles on same device). 话虽如此,请注意此错误(以及同一设备上不同配置文件的android_id有何不同)。

http://code.google.com/p/android/issues/detail?id=42523 http://code.google.com/p/android/issues/detail?id=42523

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM