1

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;

3 Answers 3

2

Another option is:

adb shell cat /sys/class/android_usb/android0/iSerial 
Sign up to request clarification or add additional context in comments.

Comments

0

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).

Comments

0

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); 

1 Comment

Thanks for the pointer. The sample AdbTest shows how to do that... unfortunately it uses a class that isn't available until version 12.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.