在 Android 设备上,有没有一种方法可以以编程方式获取 ADB 中显示的 USB 序列号?

发布于 2024-12-29 06:28:43 字数 193 浏览 3 评论 0原文

在 Android 设备上,有没有一种方法可以以编程方式获取 ADB 中显示的 USB 序列号?

Secure.getString(mApp.getContentResolver(), Secure.ANDROID_ID) 与 ADB 中显示的不同。

编辑:注意这个问题的日期。之前就问过有android.os.Build.SERIAL;

On an Android device is there a way to programmatically get the USB serial number as shown in ADB?

Secure.getString(mApp.getContentResolver(), Secure.ANDROID_ID) is different then what is shown in ADB.

EDIT: Note the date of this question. It was asked before there was android.os.Build.SERIAL;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我早已燃尽 2025-01-05 06:28:43

另一种选择是:

adb shell cat /sys/class/android_usb/android0/iSerial

Another option is:

adb shell cat /sys/class/android_usb/android0/iSerial
佼人 2025-01-05 06:28:43

获取序列号的最简单方法是:

String deviceSerialNumberFromADB = android.os.Build.SERIAL;

该序列号等于:命令提示符下的“adb get-serialno”或“adb devices”(如果仅连接 1 个设备)。

The easiest way to obtain serial number is :

String deviceSerialNumberFromADB = android.os.Build.SERIAL;

This serial number equals to: "adb get-serialno" or "adb devices" from command prompt (if only 1 device connected).

仙气飘飘 2025-01-05 06:28:43

您在这里有几个选择。如果您想通过命令行获取序列号,您可以运行:

adb get-serialno

如果您想以某种方式在应用程序中获取此信息,请查看 AdbDevice.java

使用 UsbDeviceConnection 对象,您可以:

// UsbDeviceConnection connection
serialNo = connection.getSerial();
Log.d(TAG, "Serial number is: " +serialNo);

You have a few options here. If you wanted to get the serial number via the command line, you could run:

adb get-serialno

If you wanted to somehow get this information within your app, have a look through AdbDevice.java.

Using a UsbDeviceConnection object, you can:

// UsbDeviceConnection connection
serialNo = connection.getSerial();
Log.d(TAG, "Serial number is: " +serialNo);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文