Detailed explanation of the strongest Android simulator commands in history

Source: Internet
Author: User
Tags netspeed

 


Transfer http://www.eoeandroid.com/thread-23281-1-1.html

Android simulator ndroid SDK comes with a mobile device Simulator-it is a virtual device that can run on your computer. Android Model
You can preview, develop, and test Android applications without using physical devices.
The android simulator can simulate the typical functions and behaviors of all mobile devices except for answering and making calls.
As shown in the figure on the right, the android simulator provides a large number of navigation and control keys. You can click these keys on the mouse or keyboard to generate
Event. At the same time, it also has a screen for displaying the Android app and your own app.
To facilitate simulation and testing of applications,
Android simulator allows your application to call other programs through the Android platform service
Sequencing, network access, playing audio and video, saving and ** data, notifying users, rendering image transitions and scenarios.
The android simulator also has powerful debugging capabilities, such as logging the console output by the kernel, simulating program interruptions (such as receiving text messages or making phone calls), and simulating the latency and loss of data channels.
The following sections provide detailed information about simulators and how to use simulators in developing applications.

Enable and disable Simulators

To start the android simulator, first enter the tools/folder of the SDK, and then enter emulator or./emulator. This operation will initialize the Android system and you will be on the screen
The simulator window is displayed.
To disable the simulator, you only need to close the simulator window.

Operation Simulator

You can use the startup options and console commands of the simulator to control the behaviors and features of the simulated environment. Once the simulator starts, you can press"
To operate the simulator.
The following table summarizes the ing between the keyboard buttons and keyboard buttons of the simulator.

 

Simulator buttons Keyboard buttons
Back ESC
Menu F1OrPgup
Start F2OrPgdn
Call F3
Hanging up F4
- F5,
F6 not allocated
Power Button F7
Disable/enable all networks F8
Start tracing F9
(Valid only when there is a-trace mark)
Stop a trail F10
(Valid only when there is a-trace mark)
Home Page Home
Direction key
Left/top/right/Bottom
Keypad
4/8/6/2
Direction key
Center Creation
Keypad
5
Turn down the volume Keypad
Negative number (-)
Increase the volume Keypad
Plus sign (+)


Simulator startup options

The android simulator provides many startup options that you can specify when starting the simulator to control its appearance and behavior. Below is the Life Cycle
To start the simulator in line mode and specify the syntax of parameters:

  • Emulator [-Option [value]... [-qemu ARGs]

The following table summarizes all valid options.

 

Type Option Description Note
Help -Help Print all commands of the simulator in the form of a list
Data -Data Use <File> As a disk image of user data If no-data exists, the simulator will ~ /. Android (Linux/MAC) or C:/Documents and Settings/<user>/local
In settings/Android (Windows), find the file named "userdata. IMG.
If-data is used
<File> but <File> does not exist. The simulator creates a file in that location.
-Ramdisk <File> Use <File> As a ram Image The default value is <system>/ramdisk. IMG.
-Sdcard <File> Use <File>
As an SD card image
The default value is <system>/sdcard. IMG.
-Wipe-Data Clear all data in the user's disk image before startup (refer to-data)
Debugging -Console Allow the Current Interruption to use the console Shell
-Debug-Kernel Send kernel output to the console
-Logcat <logtags> Allow output Classification Based on given tags If the environment variable android_log_tags is defined and is not empty,
The value is used as the default value of logcat.
-Trace <Name> Allow Code profiling (start with the F9 key)
-Verbose Allow detailed information output
-Verbosekeys Allow detailed output of key information
Media -MIC <device or
File>
Use a device or WAV file as the audio output
-Noaudio Disable Android audio support Disabled by default
-Radio <device> Redirect wireless modem interface to host feature Device
-Useaudio Enable Android audio support Disabled by default
Network -Netdelay <delay> Set the delay time for network latency simulation to <delay>. The default value is none. See the supported <delay> values in [url = http: // #. e7.bd. 91. e9.80.9f. e6.a8. a1.e6.8b. 9f] network latency simulation [/url] Table"
-Netfast -Netspeed full-netdelay
None shortcut
-Netspeed <speed> Set the acceleration value of the network speed simulation to <speed>. The default value is full. See the supported <speed> values in [url = http: // #. e7.bd. 91. e9.80.9f. e6.a8. a1.e6.8b. 9f] network speed simulation [/url] Table"
System -Image <File> Use <File> as a system image The default value is <system>/system. IMG.
-Kernel <File> Use <File>
As the simulator Kernel
-Nojni  
-Qemu Pass qemu Parameters
-Qemu-H Display qemu help information
-System <dir> Search for system, ram, and user data images in the <dir> directory
UI -Flashkeys The key that flashes on the device skin.
-Noskin Do not use any simulator skin
-Onion <image> Overwrite a graph on the screen Images in JPEG format are not supported. Only images in PNG format are supported.
-Onion-alpha
<Percent>
Specifies the translucent value of the onion skin (Unit: % ). The default value is 50.
-Skin <skinid> Start the simulator with the specified skin The SDK provides four Skin options:
QVGA-L (320x240, landscape) (default) QVGA-P (240x320, portrait) HVGA-L
(480x320, landscape) HVGA-P (320x480, portrait)
-Skindir <dir> Search for skin in the <dir> directory


Use the simulator Console

Every running simulator instance includes a console. You can use the console to dynamically query and control the simulated device environment.
. For example, you can use the console to dynamically manage port ing and network features, and simulate telephone time. To enter
Command, you need to use Telnet to connect to the Console port number.

You can use the following command to connect to any running simulator instance anytime, anywhere:

  • Telnet localhost <port>

Assume that the console of the first simulator instance uses port 5554, and the port number of the next instance is added with 2, such as port 5556, port 5558, and port ......
. You can use the-verbose option to check the port number used by the simulator instance at startup.
Find the output using "emulator console running on port"Number"This line. In addition, you can use ADB in the command line
Devices to view the simulator instance and their port list. Up to 16 simulations can be performed.
Instance to run the console at the same time.

Note: The simulator ** port 5554-5587 is connected from any computer. Only the current version will be accepted for future releases.
But currently, you need to use a firewall to block external connections to the 5554-5587 ports of your devices.
Once you connect to the console, you can enter help
[Command] to view the command list and the specified command tutorial.
To exit the console session,
Use the quit or exit command.
The following sections describe the main functional areas of the console.

Port redirection

You can add or delete port redirection during simulator running. After connecting to the console, you can use the following method to manage the port
Redirection:

  • Redir <list | add | del> redir

Sub-commands listed in the following table are supported:

 

Sub-commands Description Note
List List current port redirection (Min
150, Max 550)
Add
<Protocol>:
Add new port redirection <Protocol>
"TCP" or "UDP" Is the port number that sends data to the simulator/device.
Del
<Protocol>:
Delete port redirection <Protocol>
And


Network Conditions

You can use the console to detect network conditions, current latency, and acceleration features. To detect the network status, you must connect to the console and use the netstatus command. The following is an example of command and output.

  • Network Status

Network latency Simulation

The simulator allows you to simulate multiple network latency levels,
Therefore, you can test your application in a more realistic environment. You
You can set the latency level or range when the simulator starts, or you can dynamically modify the latency during the simulator running through the console.

To set latency during startup simulation, use the-netdelay option followed by a valid <delay> value. Here are some examples:

  • Emulator-netdelay GPRS
  • Emulator-netdelay 40 100

To dynamically modify network latency during simulator running, you need to connect to the console and use the netdelay command, followed by a valid <delay> value. The following table lists valid <delay> values.

  • Network Delay GPRS <delay>

The value format is as follows (unit: milliseconds ):

 

Value Description Note
GPRS GPRS (Min
150, Max 550)
Edge EDGE/EGPRS (Min
80, Max 400)
UMTS UMTS/3G (Min
(35, max 200)
None No Delay (Min
0, Max 0)
<Num> Simulate an accurate latency (milliseconds)
<Min>: <max> Simulate a specified delay range (Min,
Max ms)


Network speed simulation

The simulator also allows you to simulate multiple network transmission speeds. You can specify the transmission speed or range when the simulator is started, or
After the simulator is started, the transmission speed is dynamically modified on the console.
To set the network transmission speed when the simulator starts, use the-netspeed option followed by a valid <speed> value. The following are some examples:

  • Emulator-netspeed GSM
  • Emulator-netspeed14.4 80

To dynamically change the network transmission speed during simulator running, you need to connect to the console and use the netspeed command, which is followed by a valid <speed> value. The following table lists valid <speed> values.

  • Network Speed 14.4 80

The <speed> value format is as follows (unit: kb/s ):

 

Value Description Note
GSM GSM/CSD (Up:
14.4, down: 14.4)
HSCSD HSCSD (Up:
14.4, down: 43.2)
GPRS GPRS (Up:
40.0, down: 80.0)
Edge EDGE/EGPRS (Up:
118.4, down: 236.8)
UMTS UMTS/3G (Up:
128.0, down: 1920.0)
HSDPA HSDPA (Up:
348.0, down: 14400.0)
Full Unlimited (Up:
0.0, down: 0.0)
<Num> Set an accurate public upstream and downstream speed
<Up>: <down> Set the exact speed for the upstream and downstream respectively


Telephone function simulation

The android simulator has its own GSM module that allows you to simulate the phone function on the simulator. For example, you can simulate incoming calls and build
Establish/terminate a data connection. The phone call simulation in the Android system is the same as the actual situation. This version currently does not support phone recording.
You can access the phone function of the simulator through the console. After connecting to the console, you can use

  • GSM <CALL | data | voice>

To call the call function.
The GSM command supports the sub-commands listed in the following table.

 

Sub-commands Description Note
Call <phonenumber> Simulate a call from a phone number <phonenumber>
Voice <State> Modify the status of the GPRS voice connection to <State> Valid <State> values:
Unregistered-no available network home-in the region network, no roaming-in the roaming network searching-find network denied-only use emergency call off-
Same as 'unregistered' on-same as 'home'
Data <State> Modify the status of the GPRS data connection to <State>. Valid <State> values:
Unregistered-no available network home-in the region network, no roaming-in the roaming network searching-find network denied-only use emergency call off-
Same as 'unregistered' on-same as 'home'


Use simulator skin

You can have the simulator use one of the four skins described in the following table. To specify the skin, use-skin in the startup simulator.
<Skinid> option.
For example:

  • Emulator-skin HVGA-L

Note: <skinid> must be in uppercase (If your development device is sensitive ).

 

Skin ID Description  
QVGA-L 320 × 240,
Landscape screen (default)
 
QVGA-P 240 × 320,
Portrait Screen
 
HVGA-L 480 × 320,
Landscape Screen
 
HVGA-P 320 × 480,
Portrait Screen
 


 

Run multiple simulator instances

If necessary, you can run multiple simulator instances at the same time. Each simulator instance uses independent user data memory and different
Console port. This allows you to manage each simulator instance independently.
However, if you want to run multiple simulator instances, pay attention to the ability of each instance to store persistent user data across sessions-user
Set and install applications-restricted. The details are as follows:

  • Only the first simulator instance can save user data according to the session. By default, it stores user data on the development device ~ /. Android/userdata. IMG (on Linux and
    Mac) or C:/Documents ents and
    Settings/<user>/Local Settings/Android/userdata. IMG (on Windows) file. You can use the-data option when starting the simulator to control the storage (and loading) Location of user data (see startup options ).
  • The simulator instances started after the first instance (parallel) also save user data during the session; but they areNoSave it for the next session. These instances store data in temporary files. When the instance exits, the corresponding temporary files will be deleted.

Install the application on the simulator

To install the application on the simulator, you must use the ADB tool.
Note: The simulator saves user settings and installed programs by restarting. By default, the simulator saves data in the first
Files. In Linux and Mac operating systems, the simulator uploads user data in ~ /. Android/userdata. IMG. In Windows, the simulator saves data in C:/documents and
Settings/<user>/local
Settings/Android/userdata. IMG. The simulator uses the content of userdata. imgfile as the data/directory.

SD card Simulation

You can create a disk image and load it when the simulator starts to simulate the user's SD card on the device. The following sections describe how to create
Create a disk image, copy a file to a disk image, and load a mirror when the simulator starts.
Note: The disk image can only be loaded when the simulator is started. Similarly, the SD card cannot be removed when the simulator is running. However, you can use ADB
Or the simulator browses, sends, copies, and deletes files on the simulated SD card.
Note that the size of the simulated SD card cannot exceed 2 GB.

Create a disk image

You can use the mksdcard tool in the SDK to create a FAT32 disk image that can be loaded when the simulator starts. You can
Find the mksdcard in the tools/directory and run the following command to check the disk image:

  • Mksdcard <size> <File>
  • Example:
  • Mksdcard 512 m sd. IMG // This will generate a m SD. imgfile in the tools directory
  • Start a simulator with an SD card:
  • Emulator-AVD G2-sdcard SD. IMG // G2 is the AVD name previously set

Copy a file to a disk image

Once you create a disk image, you can copy the file to the image before the simulator loads it. To copy an object, you can
Load the image as a cyclic device and copy the file to it. Alternatively, you can use mcopy in the mtools toolkit to directly copy the file
Image. The mtools package can be used in Linux, Mac, and windows.

Load the disk image when the simulator starts

To load a disk in the FAT32 format in the simulator, enable the simulator with the-sdcard flag and specify the image name.
Name and path (relative to the current working directory ):

  • Emulator-sdcard <filepath>

Troubleshooting

The ADB tool regards the simulator as a real physical device. Therefore, you need to add the-D mark when using the ADB command, such as install. -D
Mark a device that allows you to specify which device to use as the Command target among multiple connected devices. If-D is not specified, the simulator selects the first device in the list. For more information about ADB, see android
Debug bridge.
For simulators running on Mac OS X, if you encounter "Warning: No DNS servers
Found "error. Check whether the/etc/resolv. conf file exists. If not, run the following command in the Command window:

  • Ln-S/private/var/run/resolv. CONF/etc/resolv. conf

Limitations of Simulators

This version of the simulator has the following restrictions:

  • Calls and calls are not supported. However, you can simulate calls (incoming and outgoing calls) on the console)
  • USB connection not supported
  • Camera/video capturing not supported
  • Audio input (capture) is not supported, but output (replay) is supported)
  • Extended headphones not supported
  • Unable to determine the connection status
  • Unable to determine battery level and AC charging status
  • Unable to determine the SD card insertion/pop-up
  • Bluetooth is not supported

     

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.