Search code examples
androidusbserial-number

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


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;


Solution

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