Settings.Secure.ANDROID_ID不是唯一的,如何解决? [英] Settings.Secure.ANDROID_ID is not unique, how to solve?

查看:438
本文介绍了Settings.Secure.ANDROID_ID不是唯一的,如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临一个大问题.如Android官方参考中所述: http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

I'm facing now a big issue. As found in Android official reference: http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

公共静态最终字符串ANDROID_ID

*已在API级别3中添加

*Added in API level 3

在设备的首次启动时随机生成的64位数字(作为十六进制字符串),并且在设备的整个生命周期内应保持不变.(如果在设备上执行了出厂重置,则该值可能会更改.)常量值:"android_id" *

A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.) Constant Value: "android_id"*

但是售出的 500平板电脑(A10 AllWinner)并不是真正随机生成的ANDROID_ID,而且我从我的网络服务日志中看到,有几个设备具有相同的编号

But with over 500 tablet sold (A10 AllWinner) ANDROID_ID is not really generated randomly and I see (from my web service log) that several devices have the same number!

为什么?

如何解决此问题?如何生成唯一的ID?假设所有设备的序列号始终相同(

How can I solve this issue? How can I generate a unique ID? Assume that the serial code is always the same for all devices (Same serial number on several android devices. Adb is useless. How can I change the serial number?) and MAC address could not be always available.

推荐答案

总体上,这是Android的一个严重问题-似乎Android ID是最好的选择,但您会注意到一些重要的供应商对实现方式一无所知

In general this is a serious problem with Android - it seems the Android ID is the best option BUT as you note several significant vendors have made a mess of the implementation.

面对类似的要求,我使用了这些值的哈希值:

Confronted by a similar requirement I have used a hash of these values:

  • 电话号码/SIM卡号码(如果可用或仅使用零)
  • Android ID
  • Mac地址(如果可用或仅使用零)

根据我有限的经验(使用数百种设备),这种组合足以满足您所需的独特性.

In my limited experience (several hundred devices in use) this combination has been good enough to achieve the uniqueness you need.

更新2017年从Android 6开始,由于安全原因,Mac地址返回一个恒定值-但是,在几乎所有较新的android实现中,android ID似乎都是可靠的唯一,因此,除非您以较早的版本为目标,否则就没有动机使用此技术.

Update 2017 from Android 6 the Mac address returns a constant value for security reasons - however in almost all newer implementations of android the android ID seems to be reliably unique so unless you are targeting older versions you would have no motive to use this technique.

这篇关于Settings.Secure.ANDROID_ID不是唯一的,如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆