Android 设备 ID(不是 IMEI)
我使用命令:adb devices 列出连接的设备。 在我的电脑上我得到: 附加设备列表 HT9CTP820988 设备
我的问题是:如何以编程方式获取此 id (HT9CTP820988) ?
I use the command: adb devices to list the attached devices.
On my computer I get :
List of devices attached
HT9CTP820988 device
My question is: how can I get this id (HT9CTP820988) programmatically ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您使用
adb devices
命令看到的是序列号:(参考:http://developer.android.com/guide/developing /tools/adb.html)
当您问“如何以编程方式获取此 id”时,您到底是什么意思?从 Android 应用程序还是从桌面应用程序?
What you're seeing with the
adb devices
command is the serial number:(refererence: http://developer.android.com/guide/developing/tools/adb.html)
When you ask "how can I get this id programmatically" what exactly do you mean? From an Android app or from a desktop app?
这个怎么样?
http://developer.android.com/reference/android/provider /Settings.Secure.html#ANDROID_ID
编辑:嗯,我记得这一点,这不可能是正确的; ANDROID_ID 应该是 64 位。也许您看到的字符串是由 USB 驱动程序给出的?
How about this one?
http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID
edit: Hmm I recall this, it can't be right; the ANDROID_ID is supposed to be 64-bit. Maybe the string you see is given by the USB driver?
查看
Settings.ACTION_DEVICE_INFO_SETTINGS
以及过去已经给出的答案 如何查找Android 设备?Look at
Settings.ACTION_DEVICE_INFO_SETTINGS
and answers that have already been given in the past How to find serial number of Android device?我认为模拟器id的目的是识别开发环境中的模拟器和设备。并且可能无法通过电话访问。
I think the emulator id's purpose is to identify the emulator and devices in the development environment. And it may not be accessible from the phone.
可以通过更改 drivers/usb/gadget/android.c 中的 *strings_dev* 结构来实现
It's possible by changing *strings_dev* struct from drivers/usb/gadget/android.c
我正在使用以下代码...
I'm Using the following code...