如何获取设备的android_id?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3354021/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to obtain the android_id of a device?
提问by Janusz
Possible Duplicate:
Is there a unique Android device ID?
In the licensing documentation the android developers mention an easy way to more or less securely identify an android device. They are using android.Settings.Secure.ANDROID_ID.
在许可文档中,android 开发人员提到了一种或多或少安全地识别 android 设备的简单方法。他们正在使用 android.Settings.Secure.ANDROID_ID。
They say they query the system settings for this. But they don't explain this any further.
他们说他们会为此查询系统设置。但他们没有进一步解释这一点。
How do I obtain the android_id and do I need special permissions for doing so?
我如何获取 android_id 并且这样做需要特殊权限吗?
采纳答案by Christopher Orr
It's all in the Javadoc, as linked to by this question you edited 30 minutes before this one! :)
Is there a unique Android device ID?
这一切都在 Javadoc 中,正如您在此问题之前 30 分钟编辑的问题所链接的那样!:)
是否有唯一的 Android 设备 ID?
The "Secure" part just means that apps can't write to it, only read. I seem to recall that this device ID isn't always present; it's populated by the Market as required, perhaps.
“安全”部分只是意味着应用程序不能写入,只能读取。我似乎记得这个设备 ID 并不总是存在;它可能根据需要由市场填充。
回答by Habbah
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "SELECT value FROM secure WHERE name='android_id'"
The android id is changeable with a rooted phone... Insert a android id with:
android id 可以使用 root 手机更改...插入一个 android id:
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='IDHERE' WHERE name='android_id'"