Currently when I run adb devices
it gives me a list of devices that looks something like:
emulator-5554 device
emulator-5556 device
My goal is to find a command that I can run in the shell that takes a device name as a parameter, e.g. Nexus7
and returns the corresponding device serial, e.g. emulator-5554
. If that isn't possible, I want to be able to have a function that takes emulator-5554
as the parameter and returns Nexus7
(the opposite direction of the former function) which I will then loop over all the devices in adb devices
and figure out which one matches Nexus7
.
UPDATE
I found a workaround solution which was to specify the port number when I launch the avd and then I know which emulator maps to which avd name, but ideally I would still like to know the answer here.
Open the Settings app to check your device information: Tap About phone. Take note of your device name.
In android go to Settings > Applications > Development and tap on Device Hostname. You can then change the name and it should show up when attached to adb.
It's possible with telnet to emulator. It's not a single command unfortunately, but in general it's possible to automate it with shell. Here is the basic idea:
Find emulator's port number (5554):
$ adb devices
List of devices attached
emulator-5554 device
Telnet to emulator:
$ telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
...
OK
avd name
Nexus7
Nexus7 is the avd name.
See also this answer to find how to make telnetting in one line: https://stackoverflow.com/a/5608081
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With