Steven Dieu
Steven Dieu

Reputation: 75

How to identify an android emulator (AVD) using ADB

I use the emulator AVD and i have 3 android :

I launch the first and second android with command line :

emulator -avd test
emulator -avd test1

And after, when i use this command line :

avd devices

I have

List of devices attached
emulator-5556 device
emulator-5554 device

How i can identify my android emulator with adb (only command line)?
If it's impossible, how I can know if my device is started with "emulator" (only command line) ?

Upvotes: 6

Views: 1676

Answers (3)

Azhagusundaram Tamil
Azhagusundaram Tamil

Reputation: 2391

You can get the emulator name by executing below command

if you run Pixel_8 emulator on emulator-5554

adb -s emulator-5554 shell getprop ro.boo.qemu.avd_name

output: Pixel_8

Upvotes: 0

Neo.Mxn0
Neo.Mxn0

Reputation: 1096

My verbose solution using a bash function:

get_adb_name() {
    # Check if the argument is provided
    if [ -z "$1" ]; then
        echo "Usage: get_adb_name <device_identifier>"
        return 1
    fi

    # Use the provided device identifier to construct the adb command
    adb -s "$1" emu avd name
}

Usage:

$ get_adb_name emulator-5554
Phone_API34_2
OK

Upvotes: 0

CodeWalker
CodeWalker

Reputation: 2368

Try doing a TELNET to the AVD

emulator -avd test
emulator -avd test1

avd devices

List of devices attached 
emulator-5556 device 
emulator-5554 device

telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
...
OK
avd name
test1

Upvotes: 5

Related Questions