android.Settings.Secure.ANDROID_ID

问题描述 投票:10回答:3

我正在开发一个Android应用程序,我将使用LVL库来检查谷歌播放许可证。

阅读LVL文档后,我已经读过我必须获取android.Settings.Secure.ANDROID_ID来混淆google play响应。

但我还读到,从TelephonyManager获得的ANDROID_ID有时对于不同的设备是相同的。

首先,它在2.2之前的Android版本(“Froyo”)上并非100%可靠。此外,在主要制造商的流行手机中至少有一个被广泛观察到的错误,其中每个实例都具有相同的ANDROID_ID

真的吗?

谢谢

android telephonymanager android-identifiers
3个回答
14
投票

考虑我的情况:

Same serial number on several android devices. Adb is useless. How can I change the serial number?

所以我没有解决ADB的问题,但是为了识别我使用此代码的Android设备(使用qazxsw poi):

getDeviceId(context)

我在调用我的Web服务时使用它来识别特定的应用程序安装。如您所见,我还尝试了不同的approches,也基于TelephonyManager和ANDROID_ID。

我得到的是像xxxx-xxxx-xxxx-xxxx这样的字符串,其中x是十六进制字符。

我买了很多低成本的中国平板电脑,所有这些都有相同的DEVICE_ID和相同的序列号!!所以我的解决方案它现在运作良好。


3
投票

考虑到你引用的段落public static String getDeviceId(Context context) { String id = getUniqueID(context); if (id == null) id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); return id; } private static String getUniqueID(Context context) { String telephonyDeviceId = "NoTelephonyId"; String androidDeviceId = "NoAndroidId"; // get telephony id try { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyDeviceId = tm.getDeviceId(); if (telephonyDeviceId == null) { telephonyDeviceId = "NoTelephonyId"; } } catch (Exception e) { } // get internal android device id try { androidDeviceId = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); if (androidDeviceId == null) { androidDeviceId = "NoAndroidId"; } } catch (Exception e) { } // build up the uuid try { String id = getStringIntegerHexBlocks(androidDeviceId.hashCode()) + "-" + getStringIntegerHexBlocks(telephonyDeviceId.hashCode()); return id; } catch (Exception e) { return "0000-0000-1111-1111"; } } public static String getStringIntegerHexBlocks(int value) { String result = ""; String string = Integer.toHexString(value); int remain = 8 - string.length(); char[] chars = new char[remain]; Arrays.fill(chars, '0'); string = new String(chars) + string; int count = 0; for (int i = string.length() - 1; i >= 0; i--) { count++; result = string.substring(i, i + 1) + result; if (count == 4) { result = "-" + result; count = 0; } } if (result.startsWith("-")) { result = result.substring(1, result.length()); } return result; } ,是的,这是真的。


0
投票
comes from Google itself

Secure.ANDROID_ID对于每个设备都是唯一的。

© www.soinside.com 2019 - 2024. All rights reserved.