In this document
- Starting and stopping a console session
- Port redirection
- Geo location provider emulation
- Hardware events emulation
- Device power characteristics
- Network status
- Network delay emulation
- Network speed emulation
- Telephony emulation
- SMS emulation
- VM state
- Emulator window
- Fingerprint simulation
- Terminating a virtual device
Each running virtual device provides a console that lets you query and control the emulated device environment. For example, you can use the console to manage port redirection, network characteristics, and telephony events while your app is running on the emulator.
Note: The Emulator Console for Android Emulator 25.0.10 and higher isn't currently fully functional. We recommend that you use the emulator UI and command-line options instead, where possible. For more information, see the Android Issue Tracker and Compare Android Emulator Tools.
Starting and stopping a console session
To access the console and enter commands, from a terminal window, use
connect to the
console port and provide your authentication token. Each time the console displays
OK, it's ready to accept commands. It doesn't have a typical prompt.
To connect to the console of a running virtual device:
- Open a terminal window and enter the following command:
- After the console displays OK, enter the
- After you're connected to the console, enter console commands.
- To exit the console session, enter
telnet localhost console-port
The emulator window title lists the console port number. For example, the
window title for an emulator using console port 5554
By default, a virtual device occupies a pair of adjacent ports: a console port and an adb port. The port numbers differ by 1, with the adb port having the higher port number. The console of the first virtual device running on a particular machine uses console port 5554 and adb port 5555. Subsequent virtual device use port numbers increasing by two — for example, 5556/5557, 5558/5559, and so on, to 5584/5585. The range is 5554 to 5584 for console ports; the range is the same plus one for adb ports.
To connect to the console, you must specify a valid console port. If multiple virtual devices are running, you need to determine the console port of the virtual device you want to connect to.
adb devices command prints a list of
running virtual devices and their console port numbers. For more information, see
Querying for Emulator/Device Instances.
Note: The emulator listens for connections on ports 5554 to 5585 and accepts connections from localhost only.
Before you can enter console commands, the emulator console requires authentication.
match the contents of the
.emulator_console_auth_token file in your home directory.
If that file doesn't exist, the
telnet localhost console-port
command creates the file, which contains a randomly generated authentication token.
To disable authentication, delete the token from the
.emulator_console_auth_token file or create an empty file if it doesn't exist.
help command to see a
list of console commands and learn about specific commands.
Here's an example session:
$ telnet localhost 5554 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Android Console: Authentication required Android Console: type 'auth <auth_token>' to authenticate Android Console: you can find your <auth_token> in '/Users/me/.emulator_console_auth_token' OK $ auth 123456789ABCdefZ Android Console: type 'help' for a list of commands OK $ help Android console command help: help|h|? print a list of commands crash crash the emulator instance kill kill the emulator instance quit|exit quit control session redir manage port redirections power power related commands event simulate hardware events avd control virtual device execution finger manage emulator fingerprint geo Geo-location commands sms SMS related commands cdma CDMA related commands gsm GSM related commands rotate rotate the screen by 90 degrees try 'help <command>' for command-specific help OK $ exit Connection closed by foreign host.
The following sections describe the major functional areas of the console.
You can use the console to add and remove port redirection while the emulator is running. After you connect to the console, manage port redirection by entering the following command:
redir command supports the subcommands listed in the table below.
||List the current port redirection.|
||Add a new port redirection.||
||Delete a port redirection.||The meanings of <protocol> and <host-port> are listed in the previous row.|
Geo location provider emulation
You can use the console to set the geographic location reported to the apps running
inside an emulator. Use the
geo command to send a simple GPS fix to the
emulator, with or without NMEA 1083 formatting:
geo command supports the subcommands listed in the table below.
||Send a simple GPS fix to the virtual device.||Specify longitude and latitude in decimal degrees. Specify altitude in meters.|
||Send an NMEA 0183 sentence to the emulated device, as if it were sent from an emulated GPS modem.||
You can issue the
geo command as soon as a virtual device is running. The
emulator sets the location you enter by creating a mock location provider. This provider responds to
location listeners set by apps, and also supplies the location to the
Any app can query the location manager to obtain the
current GPS fix for the emulated device by calling:
For more information about the Location Manager, see
Hardware events emulation
event console command sends hardware events to the emulator. The syntax for this
command is as follows:
event command supports the subcommands listed in the table below.
||Send one or more events to the Android kernel.||You can use text names or integers for
||Simulate keypresses to send the specified string of characters as a message,||The message must be a UTF-8 string. Unicode posts will be reverse-mapped according to the current device keyboard. Unsupported characters will be discarded silently.|
Device power characteristics
power command controls the power state reported by the emulator to apps. The
syntax for this command is as follows:
power command supports the subcommands listed in the table below.
||Display battery and charger state.|
||Set AC charging state to on or off.|
||Change battery status as specified.|
||Set battery presence state.|
||Set battery health state.|
||Set remaining battery capacity state (0-100).|
You can use the console to check the network status and current delay and speed characteristics.
To do so, connect to the console and use the
network status command. Here's an example of
the command and its output.
Network delay emulation
The emulator lets you simulate various network latency levels, so that you can test your app in an environment more typical of the actual conditions in which it will run. You can set a latency level or range at emulator startup or you can use the console to change the latency, while the app is running in the emulator.
To set latency at emulator startup, use the
-netdelay emulator option with a
<delay> value, as listed in the table below. Here are some
emulator -netdelay gprs emulator -netdelay 40 100
To make changes to network delay while the emulator is running, connect to the console and use
netdelay command with a supported
<delay> value from the table
network delay gprs
The format of network <delay> is one of the following (numbers are milliseconds):
|GPRS||(min 150, max 550)|
|EDGE/EGPRS||(min 80, max 400)|
|UMTS/3G||(min 35, max 200)|
|No latency||(min 0, max 0)|
||Emulate an exact latency (milliseconds).|
||Emulate an specified latency range (min, max milliseconds).|
Network speed emulation
The emulator also lets you simulate various network transfer rates. You can set a transfer rate or range at emulator startup or you can use the console to change the rate, while the app is running in the emulator.
To set the network speed at emulator startup, use the
-netspeed emulator option with a supported
<speed> value, as listed in the table below. Here are some examples:
emulator -netspeed gsm emulator -netspeed 14.4 80
To make changes to network speed while the emulator is running, connect to the console and use
netspeed command with a supported
<speed> value from the table
network speed 14.4 80
The format of network
<speed> is one of the following (numbers are
||GSM/CSD||(Up: 14.4, down: 14.4)|
||HSCSD||(Up: 14.4, down: 43.2)|
||GPRS||(Up: 40.0, down: 80.0)|
||EDGE/EGPRS||(Up: 118.4, down: 236.8)|
||UMTS/3G||(Up: 128.0, down: 1920.0)|
||HSDPA||(Up: 348.0, down: 14400.0)|
||LTE||(Up: 58,000, down: 173,000)|
||EVDO||(Up: 75,000, down: 280,000)|
||no limit||(Up: 0.0, down: 0.0)|
||Set an exact rate used for both upload and download.|
||Set exact rates for upload and download separately.|
The Android emulator includes its own GSM emulated modem that lets you simulate telephony functions in the emulator. For example, you can simulate inbound phone calls, establish data connections and terminate them. The Android system handles simulated calls exactly as it would actual calls. The emulator does not support call audio.
You can use the
gsm command to access the emulator telephony functions after connecting
to the console. The syntax for this command is as follows:
gsm command supports the subcommands listed in the table below.
||Simulate an inbound phone call from
||Accept an inbound call from
||You can change a call state to "active" only if its current state is "waiting" or "held".|
||Close an outbound call to
||You can change a call state to "busy" only if its current state is "waiting".|
||Terminate an inbound or outbound phone call to/from
||Change the state of the GPRS data connection to
||Change the state of a call to "held".||You can change a call state to "held" only if its current state is "active" or "waiting".|
||List all inbound and outbound calls and their states.|
||Change the state of the GPRS voice connection to
||Report the current GSM voice/data state.||Values are those described for the
The console lets you generate an SMS message and direct it to a virtual device. Once you connect to a virtual device, you can generate an emulated incoming SMS using the following command:
sms send <senderPhoneNumber> <textmessage>
<senderPhoneNumber> contains an arbitrary numeric string.
The console forwards the SMS message to the Android framework, which passes it through to an app that handles that message type.
You can use the
vm command to control the VM on a virtual device. The syntax for
this command is as follows:
vm command supports the subcommands listed in the table below.
||Start the VM on the instance.|
||Stop the VM on the instance.|
||Display the current status of the VM (running or stopped).|
You can use the
window command to manage the emulator window. The syntax for this
command is as follows:
window command supports the subcommands listed in the table below.
||Scale the emulator window.||A number between 0.1 and 3 that sets the scaling factor. You can also specify scale as a DPI value if you add the suffix "dpi" to the scale value. A value of "auto" tells the emulator to select the best window size.|
The console provides the
finger command, allowing you to simulate,
and thus validate,
fingerprint authentication for your app. To use the command, you need SDK Tools 24.3 or higher,
and Android 6.0 (API level 23) or higher.
After you set up your app to accept fingerprint authentication, your device should display the fingerprint authentication screen, as shown in figure 1.
If you don't yet have a fingerprint ID, enroll a new fingerprint in the virtual device by selecting Settings > Security > Fingerprint and then following the enrollment instructions.
While your app displays the fingerprint authentication screen, enter
finger command to simulate finger touch and removal:
finger touch <fingerprint-id>to simulate a finger touching the sensor
finger removeto simulate finger removal
Your app should respond as if a user touched and then removed their finger from the fingerprint sensor.
Terminating a virtual device
You can terminate a virtual device through the console, using the