通过与adb设备ID匹配的代码获取ID?
有没有办法通过代码获取唯一的设备ID,并通过adb获取相同的唯一ID?
我通过 adb 知道的唯一唯一 ID 是您键入“adb devices”时显示的 ID,但我无法通过应用程序内的代码获取此 ID。
Is there a way to get a unique device ID through code, and also get that same unique ID through adb?
The only unique ID that I know of through adb is the one shown when you type "adb devices", but I am unable to get this ID through code within an app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 开发者博客上有一篇关于此主题的精彩文章。你绝对应该检查一下。
通过“adb devices”显示的标识符是设备的序列号,可能是从连接到桌面的 USB 信息中获取的。如果确实如此,您可能需要尝试:
UsbDeviceConnection.getSerial()
或
Build.SERIAL 但只能从 API 9 (Gingerbread) 开始使用。
There is a great write up on this topic over at the Android Developers Blog. You should definitely check it out.
The identifier shown via "adb devices" is the device's serial number which is probably obtained from the USB information on the connection to the desktop. If this is indeed the case, you may want to try:
UsbDeviceConnection.getSerial()
or
Build.SERIAL but it's only available from API 9 (Gingerbread) forward.