4

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 ?

2
  • Did you ever figure this out? Doesn't seem like any of the answers are correct. Commented Sep 17, 2015 at 14:20
  • Found the correct answer here: stackoverflow.com/questions/11029294/… Commented Sep 17, 2015 at 14:35

6 Answers 6

1

What you're seeing with the adb devices command is the serial number:

Serial number — A string created by adb to uniquely identify an emulator/device instance by its console port number. The format of the serial number is -. Here's an example serial number: emulator-5554

(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?

Sign up to request clarification or add additional context in comments.

Comments

0

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?

Comments

0

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?

1 Comment

String deviceId = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID); -> doesn't returns the same ID than adb devices !!
0

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.

1 Comment

The serial number is displayed in the phone settings (menu About Phone | Phone identity) !
0

It's possible by changing *strings_dev* struct from drivers/usb/gadget/android.c

Comments

0

I'm Using the following code...

String aid = Settings.Secure.getString(getContext().getContentResolver(), "android_id"); Object obj = null; try { ((MessageDigest) (obj = MessageDigest.getInstance("MD5"))).update( aid.getBytes(), 0, aid.length()); obj = String.format("%032X", new Object[] { new BigInteger(1, ((MessageDigest) obj).digest()) }); } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) { obj = aid.substring(0, 32); } 

1 Comment

In English, "bro" is considered informal. You should probably use "hello" instead.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.