Home | History | Annotate | Download | only in devices
      1 page.title=Using the Android Emulator
      2 parent.title=Managing Virtual Devices
      3 parent.link=index.html
      4 @jd:body
      5 
      6 <div id="qv-wrapper">
      7 <div id="qv">
      8 
      9   <h2>In this document</h2>
     10     <ol>
     11       <li><a href="#overview">Overview</a></li>
     12       <li><a href="#starting">Starting and Stopping the Emulator</a></li>
     13       <li><a href="#starting">Android Virtual Devices and the Emulator</a></li>
     14       <li><a href="#controlling">Controlling the Emulator</a></li>
     15       <li><a href="#startup-options">Emulator Startup Options</a></li>
     16       <li><a href="#diskimages">Working with Emulator Disk Images</a>
     17 	      <ol>
     18 	        <li><a href="#defaultimages">Default Images</a></li>
     19 	        <li><a href="#runtimeimages">Runtime Images: User Data and SD Card</a></li>
     20 	        <li><a href="#temporaryimages">Temporary Images</a></li>
     21 	      </ol>
     22 	    </li>
     23       <li><a href="#emulatornetworking">Emulator Networking</a>
     24 	      <ol>
     25           <li><a href="#networkaddresses">Network Address Space</a></li>
     26           <li><a href="#networkinglimitations">Local Networking Limitations</a></li>
     27           <li><a href="#redirections">Using Network Redirections</a></li>
     28           <li><a href="#dns">Configuring the Emulator's DNS Settings</a></li>
     29           <li><a href="#proxy">Using the Emulator with a Proxy</a></li>
     30           <li><a href="#connecting">Interconnecting Emulator Instances</a></li>
     31           <li><a href="#calling">Sending a Voice Call or SMS to Another Emulator Instance</a></li>
     32         </ol>
     33       </li>
     34     </ol>
     35 
     36   <h2>See also</h2>
     37   <ol>
     38     <li><a href="{@docRoot}guide/developing/tools/emulator.html">Android Emulator</a></li>
     39     <li><a href="{@docRoot}guide/developing/devices/managing-avds.html">Managing AVDs with AVD Manager</a></li>
     40   </ol>
     41 </div>
     42 </div>
     43 
     44 <img src="{@docRoot}images/emulator-wvga800l.png" alt="Image of the Android Emulator"
     45 width="367" height="349" style="margin-left:2em;float:right;"/>
     46 <p>The Android SDK includes a virtual mobile device emulator
     47 that runs on your computer. The emulator lets you prototype, develop, and test
     48 Android applications without using a physical device. </p>
     49 
     50 <p>The Android emulator mimics all of the hardware and software features
     51 of a typical mobile device, except that it cannot place actual phone
     52 calls. It provides a variety of navigation and control keys, which you can "press"
     53 using your mouse or keyboard to generate events for your application. It also
     54 provides a screen in which your application is displayed, together with any other
     55 Android applications running. </p>
     56 
     57 <p>To let you model and test your application more easily, the emulator utilizes
     58 Android Virtual Device (AVD) configurations. AVDs let you define certain hardware
     59 aspects of your emulated phone and allow you to create many configurations to test
     60 many Android platforms and hardware permutations. Once your application is running on
     61 the emulator, it can use the services of the Android platform to invoke other
     62 applications, access the network, play audio and video, store and retrieve data,
     63 notify the user, and render graphical transitions and themes. </p>
     64 
     65 <p>The emulator also includes a variety of debug capabilities, such as a console 
     66 from which you can log kernel output, simulate application interrupts (such as 
     67 arriving SMS messages or phone calls), and simulate latency effects and dropouts 
     68 on the data channel.</p>
     69 
     70 
     71 
     72 <h2  id="overview">Overview</h2>
     73 
     74 <p>The Android emulator is a QEMU-based application that provides a virtual ARM
     75 mobile device on which you can run your Android applications. It runs a full
     76 Android system stack, down to the kernel level, that includes a set of
     77 preinstalled applications (such as the dialer) that you can access from your
     78 applications. You can choose what version of the Android system you want to
     79 run in the emulator by configuring AVDs, and you can also customize the
     80 mobile device skin and key mappings. When launching the emulator and at runtime,
     81 you can use a variety of commands and options to control the its behaviors.
     82 </p>
     83 
     84 <p>The Android system image distributed in the SDK contains ARM machine code for
     85 the Android Linux kernel, the native libraries, the Dalvik VM, and the various
     86 Android package files (such as for for the Android framework and preinstalled
     87 applications). The emulator's QEMU layers provide dynamic binary translation of
     88 the ARM machine code to the OS and processor architecture of your development
     89 machine. </p>
     90 
     91 <p>Adding custom capabilities to the underlying QEMU services, the Android
     92 emulator supports many hardware features likely to be found on mobile devices,
     93 including: </p>
     94 
     95 <ul>
     96   <li>An ARMv5 CPU and the corresponding memory-management unit (MMU)</li>
     97   <li>A 16-bit LCD display</li>
     98   <li>One or more keyboards (a Qwerty-based keyboard and associated Dpad/Phone
     99 buttons)</li>
    100   <li>A sound chip with output and input capabilities</li>
    101   <li>Flash memory partitions (emulated through disk image files on the
    102 development machine)</li>
    103   <li>A GSM modem, including a simulated SIM Card</li>
    104 </ul>
    105 
    106 <p>The sections below provide more information about the emulator and how to use
    107 it for developing Android applications.</p>
    108 
    109 
    110 <a name="avds"></a>
    111 
    112 <h2>Android Virtual Devices and the Emulator</h2>
    113 
    114 <p>To use the emulator, you first must create one or more AVD configurations. In each
    115 configuration, you specify an Android platform to run in the emulator and the set of hardware
    116 options and emulator skin you want to use. Then, when you launch the emulator, you specify
    117 the AVD configuration that you want to load. </p>
    118 
    119 <p>To specify the AVD you want to load when starting the emulator, you use the
    120 <code>-avd</code> argument, as shown in the previous section. </p>
    121 
    122 <p>Each AVD functions as an independent device, with its own private storage for
    123 user data, SD card, and so on. When you launch the emulator with an AVD configuration,
    124 it automatically loads the user data and SD card data from the AVD directory. By default,
    125 the emulator stores the user data, SD card data, and cache in the AVD directory.</p>
    126 
    127 <p>To create and manage AVDs you use the AVD Manager UI or the <code>android</code> tool
    128 that is included in the SDK. 
    129 For complete information about how to set up AVDs, see <a
    130 href="{@docRoot}guide/developing/devices/index.html">Managing Virtual Devices</a>.</p>
    131 
    132 <a name="starting"></a>
    133 
    134 <h2>Starting and Stopping the Emulator</h2>
    135 
    136 <p>During development and testing of your application, you install and run your
    137 application in the Android emulator. You can launch the emulator as a standalone
    138 application, from a command line, or you can use it as part of your Eclipse
    139 development environment. In either case, you specify the AVD configuration to
    140 load and any startup options you want to use, as described in this document.
    141 </p>
    142 
    143 <p>You can run your application on a single instance of the emulator or,
    144 depending on your needs, you can start multiple emulator instances and run your
    145 application in more than one emulated device. You can use the emulator's
    146 built-in commands to simulate GSM phone calling or SMS between emulator
    147 instances, and you can set up network redirections that allow emulators to send
    148 data to one another. For more information, see <a href="#telephony">Telephony
    149 Emulation</a>, <a href="#sms">SMS Emulation</a>, and
    150 <a href="#emulatornetworking">Emulator Networking</a></p>
    151 
    152 <p>To start an instance of the emulator from the command line, change to the
    153 <code>tools/</code> folder of the SDK. Enter <code>emulator</code> command
    154 like this: </p>
    155 
    156 <pre>emulator -avd &lt;avd_name&gt;</pre>
    157 
    158 <p>This initializes the emulator and loads an AVD configuration (see the next
    159 section for more information about AVDs). You will see the emulator window
    160 appear on your screen. </p>
    161 
    162 <p>If you are working in Eclipse, the ADT plugin for Eclipse installs your
    163 application and starts the emulator automatically, when you run or debug
    164 the application. You can specify emulator startup options in the Run/Debug
    165 dialog, in the Target tab. When the emulator is running, you can issue
    166 console commands as described later in this document.</p>
    167 
    168 <p>If you are not working in Eclipse, see <a href="#apps">Installing Applications
    169 on the Emulator</a> for information about how to install your application.</p>
    170 
    171 <p>To stop an emulator instance, just close the emulator's window.</p>
    172 
    173 <p>For a reference of the emulator's startup commands and keyboard mapping, see
    174 the <a href="{@docRoot}guide/developing/tools/emulator.html">Android Emulator</a> document.</p>
    175 
    176 
    177 
    178 
    179 
    180 <a name="controlling"></a>
    181 
    182 
    183 <h2>Controlling the Emulator</h2>
    184 
    185 <p>You can use emulator <a href="#startup-options">startup options</a> and <a
    186 href="#console">console commands</a> to control the behaviors and
    187 characteristics of the emulated environment itself.
    188 </p>
    189 
    190 <p>When the emulator is running, you can interact with the emulated mobile
    191 device just as you would an actual mobile device, except that you use your mouse
    192 pointer to &quot;touch&quot; the touchscreen and your keyboard keys to
    193 &quot;press&quot; the simulated device keys. </p>
    194 
    195 <p>The table below summarizes the mappings between the emulator keys and and
    196 the keys of your keyboard. </p>
    197 
    198 <table  border="0" style="clear:left;">
    199   <tr>
    200     <th>Emulated Device Key </th>
    201     <th>Keyboard Key </th>
    202   </tr>
    203   <tr>
    204     <td>Home</td>
    205     <td>HOME</td>
    206   </tr>
    207   <tr>
    208     <td>Menu (left softkey)</td>
    209     <td>F2 <em>or</em> Page-up button</td>
    210   </tr>
    211   <tr>
    212     <td>Star (right softkey)</td>
    213     <td>Shift-F2 <em>or </em>Page Down</td>
    214   </tr>
    215   <tr>
    216     <td>Back</td>
    217     <td>ESC</td>
    218   </tr>
    219   <tr>
    220     <td>Call/dial button </td>
    221     <td>F3</td>
    222   </tr>
    223   <tr>
    224     <td>Hangup/end call button</td>
    225     <td>F4</td>
    226   </tr>
    227   <tr>
    228     <td>Search</td>
    229     <td>F5 </td>
    230   </tr>
    231   <tr>
    232     <td>Power button</td>
    233     <td>F7 </td>
    234   </tr>
    235   <tr>
    236     <td>Audio volume up button</td>
    237     <td>KEYPAD_PLUS, Ctrl-5</td>
    238   </tr>
    239 
    240   <tr>
    241     <td>Audio volume down button</td>
    242     <td>KEYPAD_MINUS, Ctrl-F6</td>
    243   </tr>
    244   <tr>
    245     <td>Camera button</td>
    246     <td>Ctrl-KEYPAD_5, Ctrl-F3</td>
    247   </tr>
    248   <tr>
    249     <td>Switch to previous layout orientation (for example, portrait, landscape)</td>
    250     <td>KEYPAD_7, Ctrl-F11</td>
    251   </tr>
    252   <tr>
    253     <td>Switch to next layout orientation (for example, portrait, landscape)</td>
    254     <td>KEYPAD_9, Ctrl-F12</td>
    255   </tr>
    256   <tr>
    257     <td>Toggle cell networking on/off</td>
    258     <td>F8</td>
    259   </tr>
    260   <tr>
    261     <td>Toggle code profiling</td>
    262     <td>F9 (only with <code>-trace</code> startup option)</td>
    263   </tr>
    264   <tr>
    265     <td>Toggle fullscreen mode</td>
    266     <td>Alt-Enter</td>
    267   </tr>
    268   <tr>
    269     <td>Toggle trackball mode</td>
    270     <td>F6</td>
    271   </tr>
    272   <tr>
    273     <td>Enter trackball mode temporarily (while key is pressed)</td>
    274     <td>Delete</td>
    275   </tr>
    276   <tr>
    277     <td>DPad left/up/right/down</td>
    278     <td>KEYPAD_4/8/6/2</td>
    279   </tr>
    280   <tr>
    281     <td>DPad center click</td>
    282     <td>KEYPAD_5</td>
    283   </tr>
    284   <tr>
    285     <td>Onion alpha increase/decrease</td>
    286     <td>KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)</td>
    287   </tr>
    288 </table>
    289 
    290 <p>Note that, to use keypad keys, you must first disable NumLock on your development computer. </p>
    291 
    292 <h2 id="emulator">Emulator Startup Options</h2>
    293 
    294 <p>The emulator supports a variety of options that you can specify
    295 when launching the emulator, to control its appearance or behavior.
    296 Here's the command-line usage for launching the emulator with options: </p>
    297 
    298 <pre>emulator -avd &lt;avd_name&gt; [-&lt;option&gt; [&lt;value&gt;]] ... [-&lt;qemu args&gt;]</pre>
    299 
    300 <p>The table below summarizes the available options.</p>
    301 
    302 <table>
    303 <tr>
    304   <th width="10%" >Category</th>
    305   <th width="20%" >Option</th>
    306     <th width="30%" >Description</th>
    307     <th width="40%" >Comments</th>
    308 </tr>
    309 
    310 <tr>
    311   <td rowspan="9">Help</td>
    312   <td><code>-help</code></td>
    313   <td>Print a list of all emulator options.</td>
    314   <td>&nbsp;</td>
    315 </tr>
    316 <tr>
    317   <td><code>-help-all</code></td>
    318   <td>Print help for all startup options.</td>
    319   <td>&nbsp;</td>
    320 </tr>
    321 <tr>
    322   <td><code>-help-&lt;option&gt;</code></td>
    323   <td>Print help for a specific startup option.</td>
    324   <td>&nbsp;</td>
    325 </tr>
    326 <tr>
    327   <td><code>-help-debug-tags</code></td>
    328   <td>Print a list of all tags for <code>-debug &lt;tags&gt;</code>.</td>
    329   <td>&nbsp;</td>
    330 </tr>
    331 <tr>
    332   <td><code>-help-disk-images</code></td>
    333   <td>Print help for using emulator disk images.</td>
    334   <td>&nbsp;</td>
    335 </tr>
    336 <tr>
    337   <td><code>-help-environment</code></td>
    338   <td>Print help for emulator environment variables.</td>
    339   <td>&nbsp;</td>
    340 </tr><tr>
    341   <td><code>-help-keys</code></td>
    342   <td>Print the current mapping of keys.</td>
    343   <td>&nbsp;</td>
    344 </tr>
    345 <tr>
    346   <td><code>-help-keyset-file</code></td>
    347   <td>Print help for defining a custom key mappings file.</td>
    348   <td>&nbsp;</td>
    349 </tr>
    350 <tr>
    351   <td><code>-help-virtual-device</code></td>
    352   <td>Print help for Android Virtual Device usage.</td>
    353   <td>&nbsp;</td>
    354 </tr>
    355 <tr>
    356   <td>AVD</td>
    357   <td><code>-avd &lt;avd_name&gt;</code> or <br>
    358       <code>@&lt;avd_name&gt;</code></td>
    359   <td><strong>Required</strong>. Specifies the AVD to load for this emulator
    360       instance.</td>
    361   <td>You must create an AVD configuration before launching the emulator. For
    362       information, see <a href="{@docRoot}guide/developing/devices/managing-avds.html">Managing
    363       Virtual Devices with AVD Manager</a>.</td>
    364 <tr>
    365   <td rowspan="7">Disk Images</td>
    366   <td><code>-cache&nbsp;&lt;filepath&gt;</code></td>
    367   <td>Use &lt;filepath&gt; as the working cache partition image. </td>
    368   <td>Optionally, you can specify a path relative to the current working directory.
    369   If no cache file is specified, the emulator's default behavior is to use a temporary file instead.
    370   <p>For more information on disk images, use <code>-help-disk-images</code>.</p>
    371 </td></tr>
    372 <tr>
    373   <td><code>-data&nbsp;&lt;filepath&gt;</code></td>
    374   <td>Use &lt;filepath&gt; as the working user-data disk image. </td>
    375   <td>Optionally, you can specify a path relative to the current working directory.
    376   If <code>-data</code> is not used, the emulator looks for a file named &quot;userdata-qemu.img&quot;
    377   in the storage area of the AVD being used (see <code>-avd</code>).
    378 </td></tr>
    379 <!--
    380 <tr>
    381   <td><code>-datadir &lt;dir&gt;</code></td>
    382   <td>Search for the user-data disk image specified in <code>-data</code> in &lt;dir&gt;</td>
    383   <td><code>&lt;dir&gt;</code> is a path relative to the current working directory.
    384 
    385 <p>If you do not specify <code>-datadir</code>, the emulator looks for the user-data image
    386 in the storage area of the AVD being used (see <code>-avd</code>)</p><p>For more information
    387 on disk images, use <code>-help-disk-images</code>.</p>
    388 </td></tr>
    389 -->
    390 <!-- 
    391 <tr>
    392   <td><code>-image&nbsp;&lt;filepath&gt;</code></td>
    393   <td>Use &lt;filepath&gt; as the system image.</td>
    394   <td>Optionally, you can specify a path relative to the current working directory.
    395    Default is &lt;system&gt;/system.img.</td>
    396 </tr>
    397 -->
    398 <tr>
    399   <td><code>-initdata&nbsp;&lt;filepath&gt;</code></td>
    400   <td>When resetting the user-data image (through <code>-wipe-data</code>), copy the contents
    401   of this file to the new user-data disk image. By default, the emulator copies the <code>&lt;system&gt;/userdata.img</code>.</td>
    402   <td>Optionally, you can specify a path relative to the current working directory. See also <code>-wipe-data</code>.
    403   <p>For more information on disk images, use <code>-help-disk-images</code>.</p></td>
    404 </tr>
    405 <!--
    406 <tr>
    407   <td><code>-kernel&nbsp;&lt;filepath&gt;</code></td>
    408   <td>Use &lt;filepath&gt; as the emulated kernel.</td>
    409   <td>Optionally, you can specify a path relative to the current working directory. </td>
    410 </tr>
    411 -->
    412 <tr>
    413   <td><code>-nocache</code></td>
    414   <td>Start the emulator without a cache partition.</td>
    415   <td>See also <code>-cache &lt;file&gt;</code>.</td>
    416 </tr>
    417 <tr>
    418   <td><code>-ramdisk&nbsp;&lt;filepath&gt;</code></td>
    419   <td>Use &lt;filepath&gt; as the ramdisk image.</td>
    420   <td>Default value is <code>&lt;system&gt;/ramdisk.img</code>.
    421   <p>Optionally, you can specify a path relative to the current working directory. 
    422   For more information on disk images, use <code>-help-disk-images</code>.</p>
    423 </td>
    424 </tr>
    425 <tr>
    426   <td><code>-sdcard&nbsp;&lt;filepath&gt;</code></td>
    427   <td>Use &lt;file&gt; as the SD card image.</td>
    428   <td>Default value is <code>&lt;system&gt;/sdcard.img</code>.
    429   <p>Optionally, you can specify a path relative to the current working directory. For more information on disk images, use <code>-help-disk-images</code>.</p>
    430 </td>
    431 </tr>
    432 <!--
    433 <tr>
    434  <td><code>-system&nbsp;&lt;dirpath&gt;</code></td>
    435  <td>Search for system, ramdisk and user data images in &lt;dir&gt;.</td>
    436  <td><code>&lt;dir&gt;</code> is a directory path relative to the current 
    437   working directory.</td>
    438 </tr>
    439 -->
    440 <tr>
    441   <td><code>-wipe-data</code></td>
    442   <td>Reset the current user-data disk image (that is, the file specified by <code>-datadir</code> and 
    443   <code>-data</code>, or the default file). The emulator deletes all data from the user data image file, 
    444   then copies the contents of the file at <code>-inidata</code> data to the image file before starting. 
    445   </td>
    446   <td>See also <code>-initdata</code>. 
    447   <p>For more information on disk images, use <code>-help-disk-images</code>.</p>
    448 </td>
    449 </tr>
    450 <tr>
    451   <td rowspan="9">Debug</td>
    452   <td><code>-debug &lt;tags&gt;</code></td>
    453   <td>Enable/disable debug messages for the specified debug tags.</td>
    454   <td><code>&lt;tags&gt;</code> is a space/comma/column-separated list of debug component names. 
    455   Use <code>-help-debug-tags</code> to print a list of debug component names that you can use. </td>
    456 </tr>
    457 <tr>
    458   <td><code>-debug-&lt;tag&gt;</code></td>
    459   <td>Enable/disable debug messages for the specified debug tag.</td>
    460   <td rowspan="2">Use <code>-help-debug-tags</code> to print a list of debug component names that you can use in <code>&lt;tag&gt;</code>. </td>
    461 </tr>
    462 <tr>
    463   <td><code>-debug-no-&lt;tag&gt;</code></td>
    464   <td>Disable debug messages for the specified debug tag.</td>
    465 </tr>
    466 <tr>
    467   <td><code>-logcat &lt;logtags&gt;</code></td>
    468   <td>Enable logcat output with given tags.</td>
    469   <td>If the environment variable ANDROID_LOG_TAGS is defined and not
    470     empty, its value will be used to enable logcat output by default.</td>
    471 </tr>
    472 <tr>
    473   <td><code>-shell</code></td>
    474   <td>Create a root shell console on the current terminal.</td>
    475   <td>You can use this command even if the adb daemon in the emulated system is broken. 
    476   Pressing Ctrl-c from the shell stops the emulator instead of the shell.</td>
    477 </tr>
    478 <tr>
    479   <td><code>-shell-serial&nbsp;&lt;device&gt;</code></td>
    480   <td>Enable the root shell (as in <code>-shell</code> and specify the QEMU character 
    481   device to use for communication with the shell.</td>
    482   <td>&lt;device&gt; must be a QEMU device type. See the documentation for '-serial <em>dev</em>' at 
    483   <a href="http://www.nongnu.org/qemu/qemu-doc.html#SEC10">http://www.bellard.org/qemu/qemu-doc.html#SEC10</a> 
    484   for a list of device types.
    485 
    486 <p>Here are some examples: </p>
    487 <ul>
    488   <li><code>-shell-serial stdio</code> is identical to <code>-shell</code></li>
    489   <li><code>-shell-serial tcp::4444,server,nowait</code> lets you communicate with the shell over TCP port 4444</li>
    490   <li><code>-shell-serial fdpair:3:6</code> lets a parent process communicate with the shell using fds 3 (in) and 6 (out)</li>
    491   <li><code>-shell-serial fdpair:0:1</code> uses the normal stdin and stdout fds, except that QEMU won't tty-cook the data.</li>
    492   </ul>
    493 </td>
    494 </tr>
    495 <tr>
    496   <td><code>-show-kernel &lt;name&gt;</code></td>
    497   <td>Display kernel messages.</td>
    498   <td>&nbsp;</td>
    499 </tr>
    500 <tr>
    501   <td><code>-trace &lt;name&gt;</code></td>
    502   <td>Enable code profiling (press F9 to start), written to a specified file.</td>
    503   <td>&nbsp;</td>
    504 </tr>
    505 <tr>
    506   <td><code>-verbose</code></td>
    507   <td>Enable verbose output.</td>
    508   <td>Equivalent to <code>-debug-init</code>. 
    509 <p>You can define the default verbose output options used by emulator instances in the Android environment variable 
    510 ANDROID_VERBOSE. Define the options you want to use in a comma-delimited list, specifying only the stem of each option: 
    511 <code>-debug-&lt;tags&gt;.</code> </p>
    512 <p>Here's an example showing ANDROID_VERBOSE defined with the <code>-debug-init</code> and <code>-debug-modem</code> options: 
    513 <p><code>ANDROID_VERBOSE=init,modem</code></p>
    514 <p>For more information about debug tags, use <code>&lt;-help-debug-tags&gt;</code>.</p>
    515 </td>
    516 </tr>
    517 <tr>
    518   <td rowspan="6">Media</td>
    519   <td><code>-audio &lt;backend&gt;</code></td>
    520   <td>Use the specified audio backend.</td>
    521   <td>&nbsp;</td>
    522 </tr>
    523 <tr>
    524   <td><code>-audio-in &lt;backend&gt;</code></td>
    525   <td>Use the specified audio-input backend.</td>
    526   <td>&nbsp;</td>
    527 </tr>
    528 <tr>
    529   <td><code>-audio-out &lt;backend&gt;</code></td>
    530   <td>Use the specified audio-output backend.</td>
    531   <td>&nbsp;</td>
    532 </tr>
    533 <!--<tr>
    534   <td><code>-mic &lt;device or file&gt;</code></td>
    535   <td>Use device or WAV file for audio input.</td>
    536   <td>&nbsp;</td>
    537 </tr>
    538 -->
    539 <tr>
    540   <td><code>-noaudio</code></td>
    541   <td>Disable audio support in the current emulator instance.</td>
    542   <td>&nbsp;</td>
    543 </tr>
    544 <tr>
    545   <td><code>-radio &lt;device&gt;</code></td>
    546   <td>Redirect radio modem interface to a host character device.</td>
    547   <td>&nbsp;</td></tr>
    548 <tr>
    549   <td><code>-useaudio</code></td>
    550   <td>Enable audio support in the current emulator instance.</td>
    551   <td>Enabled by default. </td>
    552 </tr>
    553 
    554 <tr>
    555   <td rowspan="7">Network</td>
    556   <td><code>-dns-server &lt;servers&gt;</code></td>
    557   <td>Use the specified DNS server(s). </td>
    558   <td>The value of <code>&lt;servers&gt;</code> must be a comma-separated list of up to 4 DNS server names or
    559   IP addresses.</td>
    560 </tr>
    561 <tr>
    562   <td><code>-http-proxy &lt;proxy&gt;</code></td>
    563   <td>Make all TCP connections through a specified HTTP/HTTPS proxy</td>
    564   <td>The value of <code>&lt;proxy&gt;</code> can be one of the following:<br>
    565      <code>http://<server>:<port>;</code><br>
    566      <code>http://<username>:<password>@<server>:<port>;</code>
    567   <p>The <code>http://</code> prefix can be omitted. If the <code>-http-proxy &lt;proxy&gt;</code> command is not supplied,
    568   the emulator looks up the <code>http_proxy</code> environment variable and automatically uses any value matching
    569   the <code>&lt;proxy&gt;</code> format described above.</p></td>
    570 </tr>
    571 <tr>
    572   <td><code>-netdelay &lt;delay&gt;</code></td>
    573   <td>Set network latency emulation to &lt;delay&gt;.</td>
    574   <td>Default value is <code>none</code>. See the table in <a href="#netdelay">Network Delay Emulation</a> for 
    575   supported <code>&lt;delay&gt;</code> values. </td>
    576 </tr>
    577 <tr>
    578   <td><code>-netfast</code></td>
    579   <td>Shortcut for <code>-netspeed full -netdelay none</code></td>
    580   <td>&nbsp;</td></tr>
    581 <tr>
    582   <td><code>-netspeed &lt;speed&gt;</code></td>
    583   <td>Set network speed emulation to &lt;speed&gt;.</td>
    584   <td>Default value is <code>full</code>. See the table in <a href="#netspeed">Network Speed Emulation</a> for 
    585   supported <code>&lt;speed&gt;</code> values. </td>
    586 </tr>
    587 <tr>
    588   <td><code>-port &lt;port&gt;</code></td>
    589   <td>Set the console port number for this emulator instance to <code>&lt;port&gt;</code>.</td>
    590   <td>The console port number must be an even integer between 5554 and 5584, inclusive. <code>&lt;port&gt;</code>+1 
    591   must also be free and will be reserved for ADB.</td>
    592 </tr>
    593 <tr>
    594   <td><code>-report-console &lt;socket&gt;</code></td>
    595   <td>Report the assigned console port for this emulator instance to a remote third party 
    596   before starting the emulation. </td>
    597   <td><code>&lt;socket&gt;</code> must use one of these formats:
    598 
    599 <p><code>tcp:&lt;port&gt;[,server][,max=&lt;seconds&gt;]</code></br>
    600 <code>unix:&lt;port&gt;[,server][,max=&lt;seconds&gt;]</code></p>
    601 
    602 <p>Use <code>-help-report-console</code></p> to view more information about this topic. </td>
    603 </tr>
    604 <tr>
    605   <td rowspan="8">System</td>
    606   <td><code>-cpu-delay &lt;delay&gt;</code></td>
    607   <td>Slow down emulated CPU speed by &lt;delay&gt; </td>
    608   <td>Supported values for &lt;delay&gt; are integers between 0 and 1000.
    609 
    610 <p>Note that the &lt;delay&gt; does not correlate to clock speed or other absolute metrics 
    611 &mdash; it simply represents an abstract, relative delay factor applied non-deterministically 
    612 in the emulator. Effective performance does not always 
    613 scale in direct relationship with &lt;delay&gt; values.</p>
    614 </td>
    615 </tr>
    616 <tr>
    617   <td><code>-gps &lt;device&gt;</code></td>
    618   <td>Redirect NMEA GPS to character device.</td>
    619   <td>Use this command to emulate an NMEA-compatible GPS unit connected to
    620   an external character device or socket. The format of <code>&lt;device&gt;</code> must be QEMU-specific 
    621   serial device specification. See the documentation for 'serial -dev' at 
    622   <a href="http://www.bellard.org/qemu/qemu-doc.html#SEC10">http://www.bellard.org/qemu/qemu-doc.html#SEC10</a>.
    623 </td>
    624 </tr>
    625 <tr>
    626   <td><code>-nojni</code></td>
    627   <td>Disable JNI checks in the Dalvik runtime.</td><td>&nbsp;</td></tr>
    628 <tr>
    629   <td><code>-qemu</code></td>
    630   <td>Pass arguments to qemu.</td>
    631   <td>&nbsp;</td></tr>
    632 <tr>
    633   <td><code>-qemu -h</code></td>
    634   <td>Display qemu help.</td>
    635   <td></td></tr>
    636 <tr>
    637   <td><code>-radio &lt;device&gt;</code></td>
    638   <td>Redirect radio mode to the specified character device.</td>
    639   <td>The format of <code>&lt;device&gt;</code> must be QEMU-specific 
    640   serial device specification. See the documentation for 'serial -dev' at 
    641 <a href="http://www.bellard.org/qemu/qemu-doc.html#SEC10">http://www.bellard.org/qemu/qemu-doc.html#SEC10</a>.
    642 </td>
    643 </tr>
    644 <tr>
    645  <td><code>-timezone &lt;timezone&gt;</code></td>
    646  <td>Set the timezone for the emulated device to &lt;timezone&gt;, instead of the host's timezone.</td>
    647  <td><code>&lt;timezone&gt;</code> must be specified in zoneinfo format. For example:
    648 <p>"America/Los_Angeles"<br>
    649 "Europe/Paris"</p>
    650 </td>
    651 </tr>
    652 <tr>
    653  <td><code>-version</code></td>
    654  <td>Display the emulator's version number.</td>
    655  <td>&nbsp;</td>
    656 </tr>
    657 <tr>
    658   <td rowspan="12">UI</td>
    659   <td><code>-dpi-device &lt;dpi&gt;</code></td>
    660   <td>Scale the resolution of the emulator to match the screen size
    661   of a physical device.</td>
    662   <td>The default value is 165. See also <code>-scale</code>.</td>
    663 </tr>
    664 <tr>
    665   <td><code>-no-boot-anim</code></td>
    666   <td>Disable the boot animation during emulator startup.</td>
    667   <td>Disabling the boot animation can speed the startup time for the emulator.</td>
    668 </tr>
    669 <tr>
    670   <td><code>-no-window</code></td>
    671   <td>Disable the emulator's graphical window display.</td>
    672   <td>&nbsp;</td>
    673 </tr>
    674 <tr>
    675   <td><code>-scale &lt;scale&gt;</code></td>
    676   <td>Scale the emulator window. </td>
    677   <td><code>&lt;scale&gt;</code> is a number between 0.1 and 3 that represents the desired scaling factor. You can 
    678   also specify scale as a DPI value if you add the suffix "dpi" to the scale value. A value of "auto" 
    679   tells the emulator to select the best window size.</td>
    680 </tr>
    681 <tr>
    682   <td><code>-raw-keys</code></td>
    683   <td>Disable Unicode keyboard reverse-mapping.</td>
    684   <td>&nbsp;</td></tr>
    685 <tr>
    686   <td><code>-noskin</code></td>
    687   <td>Don't use any emulator skin.</td>
    688   <td>&nbsp;</td></tr>
    689 <tr>
    690   <td><code>-keyset &lt;file&gt;</code></td>
    691   <td>Use the specified keyset file instead of the default.</td>
    692   <td>The keyset file defines the list of key bindings between the emulator and the host keyboard. 
    693   For more information, use <code>-help-keyset</code> to print information about this topic.
    694 </td>
    695 </tr>
    696 <tr>
    697   <td><code>-onion &lt;image&gt;</code></td>
    698   <td>Use overlay image over screen.</td>
    699   <td>No support for JPEG. Only PNG is supported.</td></tr>
    700 <tr>
    701   <td><code>-onion-alpha &lt;percent&gt;</code></td>
    702   <td>Specify onion skin translucency  value (as percent).
    703   <td>Default is 50.</td>
    704 </tr>
    705 <tr>
    706   <td><code>-onion-rotation &lt;position&gt;</code></td>
    707   <td>Specify onion skin rotation.
    708   <td><code>&lt;position&gt;</code> must be one of the values 0, 1, 2, 3.</td>
    709 </tr>
    710 <tr>
    711   <td><code>-skin &lt;skinID&gt;</code></td>
    712   <td>This emulator option is deprecated. </td>
    713   <td>Please set skin options using AVDs, rather than by using this emulator
    714 option. Using this option may yield unexpected and in some cases misleading
    715 results, since the density with which to render the skin may not be defined.
    716 AVDs let you associate each skin with a default density and override the default
    717 as needed. For more information, see <a
    718 href="{@docRoot}guide/developing/devices/managing-avds.html">Managing Virtual Devices
    719 with AVD Manager</a>.
    720 </td>
    721 </tr>
    722 <tr>
    723   <td><code>-skindir &lt;dir&gt;</code></td>
    724   <td>This emulator option is deprecated. </td>
    725   <td>See comments for <code>-skin</code>, above.</td></tr>
    726 </table>
    727 
    728 
    729 <a name="diskimages"></a>
    730 
    731 <h2>Working with Emulator Disk Images</h2>
    732 
    733 <p>The emulator uses mountable disk images stored on your development machine to
    734 simulate flash (or similar) partitions on an actual device. For example, it uses
    735 disk image containing an emulator-specific kernel, the Android system, a
    736 ramdisk image, and writeable images for user data and simulated SD card.</p>
    737 
    738 <p>To run properly, the emulator requires access to a specific set of disk image
    739 files. By default, the Emulator always looks for the disk images in the 
    740 private storage area of the AVD in use. If no images exist there when 
    741 the Emulator is launched, it creates the images in the AVD directory based on 
    742 default versions stored in the SDK. </p>
    743 
    744 <p class="note"><strong>Note:</strong> The default storage location for 
    745 AVDs is in <code>~/.android/avd</code> on OS X and Linux, <code>C:\Documents and 
    746 Settings\&lt;user&gt;\.android\</code> on Windows XP, and 
    747 <code>C:\Users\&lt;user&gt;\.android\</code>
    748 on Windows Vista.</p>
    749 
    750 <p>To let you use alternate or custom versions of the image files, the emulator
    751 provides startup options that override the default locations and filenames of
    752 the image files. When you use the options, the emulator searches for the image
    753 file under the image name or location that you specify; if it can not locate the
    754 image, it reverts to using the default names and location.</p>
    755 
    756 <p>The emulator uses three types of image files: default image files, runtime
    757 image files, and temporary image files. The sections below describe how to
    758 override the location/name of each type of file. </p>
    759 
    760 <a name="defaultimages"></a>
    761 <h3>Default Images</h3>
    762 
    763 <p>When the emulator launches but does not find an existing user data image in
    764 the active AVD's storage area, it creates a new one from a default version
    765 included in the SDK. The default user data image is read-only. The image 
    766 files are read-only.</p>
    767 
    768 <p>The emulator provides the <code>-system &lt;dir&gt;</code> startup option to
    769 let you override the location under which the emulator looks for the default
    770 user data image. </p>
    771 
    772 <p>The emulator also provides a startup option that lets you override the name
    773 of the default user data image, as described in the table below. When you use the 
    774 option, the emulator looks in the default directory, or in a custom location
    775 (if you specified <code>-system &lt;dir&gt;</code>). </p>
    776 
    777 
    778 <table>
    779 <tr>
    780   <th width="10%" >Name</th>
    781     <th width="30%" >Description</th>
    782     <th width="40%" >Comments</th>
    783 </tr>
    784 
    785 <!--
    786 <tr>
    787   <td><code>kernel-qemu.img</code></td>
    788   <td>The emulator-specific Linux kernel image</td>
    789   <td>Override using <code>-kernel &lt;file&gt;</code></td>
    790 </tr>
    791 
    792 <tr>
    793   <td><code>ramdisk.img</code></td>
    794   <td>The ramdisk image used to boot the system.</td>
    795   <td>Override using <code>-ramdisk &lt;file&gt;</code></td>
    796 </tr>
    797 
    798 <tr>
    799   <td><code>system.img</code></td>
    800   <td>The <em>initial</em> Android system image.</td>
    801   <td>Override using <code>-image &lt;file&gt;</code></td>
    802 </tr>
    803 -->
    804 <tr>
    805   <td><code>userdata.img</code></td>
    806   <td>The <em>initial</em> user-data disk image</td>
    807   <td>Override using <code>-initdata &lt;file&gt;</code>. Also see
    808 <code>-data &lt;file&gt;</code>, below.</td>
    809 </tr>
    810 
    811 </table>
    812 
    813 <a name="runtimeimages"></a>
    814 <h3>Runtime Images: User Data and SD Card</h3>
    815 
    816 <p>At runtime, the emulator reads and writes data on two disk images: a
    817 user-data image and (optionally) an SD card image. This emulates the user-data
    818 partition and removable storage media on actual device. </p>
    819 
    820 <p>The emulator provides a default user-data disk image. At startup, the emulator 
    821 creates the default image as a copy of the system user-data image (user-data.img), 
    822 described above. The emulator stores the new image with the files of the active AVD.</p>
    823 
    824 <!--
    825 <p>The emulator provides a startup option, <code>-datadir &lt;dir&gt;</code>, 
    826 that you can use to override the location under which the emulator looks for the runtime
    827 image files. </p>
    828 -->
    829 
    830 <p>The emulator provides startup options to let you override the actual names and storage 
    831 locations of the runtime images to load, as described in the table below. When you use one 
    832 of these options, the emulator looks for the specified file(s) in the current working directory,
    833 in the AVD directory, or in a custom location (if you specified a path with the filename). </p>
    834 
    835 <table>
    836 <tr>
    837   <th width="10%" >Name</th>
    838     <th width="30%" >Description</th>
    839     <th width="40%" >Comments</th>
    840 </tr>
    841 <tr>
    842   <td><code>userdata-qemu.img</code></td>
    843   <td>An image to which the emulator writes runtime user-data for a unique user.</td>
    844   <td>Override using <code>-data &lt;filepath&gt;</code>, where <code>&lt;filepath&gt;</code> is the
    845 path the image, relative to the current working directory. If you supply a filename only, 
    846 the emulator looks for the file in the current working directory. If the file at <code>&lt;filepath&gt;</code> does
    847 not exist, the emulator creates an image from the default userdata.img, stores it under the name you
    848 specified, and persists user data to it at shutdown. </td>
    849 </tr>
    850 
    851 <tr>
    852   <td><code>sdcard.img</code></td>
    853   <td>An image representing an SD card inserted into the emulated device.</td>
    854   <td>Override using <code>-sdcard &lt;filepath&gt;</code>, where <code>&lt;filepath&gt;</code> is the
    855 path the image, relative to the current working directory. If you supply a filename only, 
    856 the emulator looks for the file in the current working directory. </td>
    857 </tr>
    858 
    859 </table>
    860 
    861 <h4>User-Data Image</h4>
    862 
    863 <p>Each emulator instance uses a writeable user-data image to store user- and
    864 session-specific data. For example, it uses the image to store a unique user's
    865 installed application data, settings, databases, and files. </p>
    866 
    867 <p>At startup, the emulator attempts to load a user-data image stored during 
    868 a previous session. It looks for the file in the current working directory, 
    869 in the AVD directory as described above, and at the custom location/name 
    870 that you specified at startup. </p>
    871 
    872 <ul>
    873 <li>If it finds a user-data image, it mounts the image and makes it available 
    874 to the system for reading/writing of user data. </li>
    875 <li>If it does not find one, it creates an image by copying the system user-data
    876 image (userdata.img), described above. At device power-off, the system persists
    877 the user data to the image, so that it will be available in the next session. 
    878 Note that the emulator stores the new disk image at the location/name that you
    879 specify in <code>-data</code> startup option.</li>
    880 </ul>
    881 
    882 <p class="note"><strong>Note:</strong> Because of the AVD configurations used in the emulator,
    883 each emulator instance now gets its own dedicated storage. There is no need 
    884 to use the <code>-d</code> option to specify an instance-specific storage area.</p>
    885 
    886 <h4>SD Card</h4>
    887 
    888 <P>Optionally, you can create a writeable disk image that the emulator can use
    889 to simulate removeable storage in an actual device. For information about how to create an 
    890 emulated SD card and load it in the emulator, see <a href="#sdcard">SD Card Emulation</a></p>
    891 
    892 <p>You can also use the android tool to automatically create an SD Card image
    893 for you, when creating an AVD. For more information, see <a 
    894 href="{@docRoot}guide/developing/devices/managing-avds.html">Managing Virtual Devices with AVD
    895 Manager</a>.
    896 
    897 <a name="temporaryimages"></a>
    898 <h3>Temporary Images</h3>
    899 
    900 <p>The emulator creates two writeable images at startup that it deletes at
    901 device power-off. The images are: </p>
    902 
    903 <ul>
    904   <li>A writable copy of the Android system image</li>
    905   <li>The <code>/cache</code> partition image</li>
    906 </ul>
    907 
    908 <p>The emulator does not permit renaming the temporary system image or
    909 persisting it at device power-off. </p>
    910 
    911 <p>The <code>/cache</code> partition image is initially empty, and is used by
    912 the browser to cache downloaded web pages and images. The emulator provides an 
    913 <code>-cache &lt;file&gt;</code>, which specifies the name of the file at which 
    914 to persist the <code>/cache</code> image at device power-off. If <code>&lt;file&gt;
    915 </code> does not exist, the emulator creates it as an empty file. </p>
    916 
    917 <p>You can also disable the use of the cache partition by specifying the
    918 <code>-nocache</code> option at startup. </p>
    919 
    920 
    921 <a name="emulatornetworking"></a>
    922 <h2>Emulator Networking</h2>
    923 
    924 <p>The emulator provides versatile networking capabilities that you can use to
    925 set up complex modeling and testing environments for your application. The
    926 sections below introduce the emulator's network architecture and capabilities.
    927 </p>
    928 
    929 <a name="networkaddresses"></a>
    930 <h3>Network Address Space</h3>
    931 
    932 <p>Each instance of the emulator runs behind a virtual router/firewall service
    933 that isolates it from your development machine's network interfaces and settings
    934 and from the internet. An emulated device can not see your development machine
    935 or other emulator instances on the network. Instead, it sees only that it is
    936 connected through Ethernet to a router/firewall.</p>
    937 
    938 <p>The virtual router for each instance manages the 10.0.2/24 network address
    939 space &mdash; all addresses managed by the router are in the form of
    940 10.0.2.&lt;xx&gt;, where &lt;xx&gt; is a number. Addresses within this space are
    941 pre-allocated by the emulator/router as follows:</p>
    942 
    943 <table>
    944   <tr>
    945     <th>Network Address</th>
    946     <th>Description</th>
    947   </tr>
    948   <tr>
    949     <td>10.0.2.1</td>
    950     <td>Router/gateway address </td>
    951   </tr>
    952   <tr>
    953     <td>10.0.2.2</td>
    954     <td>Special alias to your host loopback interface (i.e., 127.0.0.1 on your
    955 development machine)</td>
    956   </tr>
    957   <tr>
    958     <td>10.0.2.3</td>
    959     <td>First DNS server</td>
    960   </tr>
    961   <tr>
    962     <td>10.0.2.4 / 10.0.2.5 / 10.0.2.6</td>
    963     <td>Optional second, third and fourth DNS server (if any) </td>
    964   </tr>
    965   <tr>
    966     <td>10.0.2.15</td>
    967     <td>The emulated device's own network/ethernet interface</td>
    968   </tr>
    969   <tr>
    970     <td>127.0.0.1</td>
    971     <td>The emulated device's own loopback interface </td>
    972   </tr>
    973 </table>
    974 
    975 <p>Note that the same address assignments are used by all running emulator
    976 instances. That means that if you have two instances running concurrently on
    977 your machine, each will have its own router and, behind that, each will have an
    978 IP address of 10.0.2.15. The instances are isolated by a router and can
    979 <em>not</em> see each other on the same network. For information about how to
    980 let emulator instances communicate over TCP/UDP, see <a
    981 href="#connecting">Connecting Emulator Instances</a>.</p>
    982 
    983 <p>Also note that the address 127.0.0.1 on your development machine corresponds
    984 to the emulator's own loopback interface. If you want to access services running
    985 on your development machine's loopback interface (a.k.a. 127.0.0.1 on your
    986 machine), you should use the special address 10.0.2.2 instead.</p>
    987 
    988 <p>Finally, note that each emulated device's pre-allocated addresses are
    989 specific to the Android emulator and will probably be very different on real
    990 devices (which are also very likely to be NAT-ed, i.e., behind a
    991 router/firewall)</p>
    992 
    993 <a name="networkinglimitations"></a>
    994 <h3>Local Networking Limitations</h3>
    995 
    996 <p>Each emulator instance runs behind a virtual router, but unlike an actual
    997 device connected to a physical router, the emulated device doesn't have access
    998 to a physical network. Instead it runs as part of a normal application on your
    999 development machine. This means that it is subject to the same networking
   1000 limitations as other applications on your machine:</p>
   1001 
   1002 <ul>
   1003   <li>Communication with the emulated device may be blocked by a firewall
   1004 program running on your machine.</li>
   1005   <li>Communication with the emulated device may be blocked by another
   1006 (physical) firewall/router to which your machine is connected.</li>
   1007 </ul>
   1008 
   1009 <p>The emulator's virtual router should be able to handle all outbound TCP and
   1010 UDP connections/messages on behalf of the emulated device, provided your
   1011 development machine's network environment allows it to do so. There are no
   1012 built-in limitations on port numbers or ranges except the one imposed by your
   1013 host operating system and network.</p>
   1014 
   1015 <p>Depending on the environment, the emulator may not be able to support other
   1016 protocols (such as ICMP, used for "ping") might not be supported. Currently, the
   1017 emulator does not support IGMP or multicast. </p>
   1018 
   1019 <a name="redirections"></a>
   1020 <h3>Using Network Redirections</h3>
   1021 
   1022 <p>To communicate with an emulator instance behind its virtual router, you need
   1023 to set up network redirections on the virtual router. Clients can then connect
   1024 to a specified guest port on the router, while the router directs traffic
   1025 to/from that port to the emulated device's host port. </p>
   1026 
   1027 <p>To set up the network redirections, you create a mapping of host and guest
   1028 ports/addresses on the the emulator instance. There are two ways to set up
   1029 network redirections: using emulator console commands and using the ADB tool, as
   1030 described below. </p>
   1031 
   1032 <a name="consoleredir"></a>
   1033 <h4>Setting up Redirections through the Emulator Console</h4>
   1034 
   1035 <p>Each emulator instance provides a control console the you can connect to, to
   1036 issue commands that are specific to that instance. You can use the
   1037 <code>redir</code> console command to set up redirections as needed for an
   1038 emulator instance. </p>
   1039 
   1040 <p>First, determine the console port number for the target emulator instance.
   1041 For example, the console port number for the first emulator instance launched is
   1042 5554. Next, connect to the console of the target emulator instance, specifying
   1043 its console port number, as follows: </p>
   1044 
   1045 <pre><code>telnet localhost 5554</code></pre>
   1046 
   1047 <p>Once connected, use the <code>redir</code> command to work with redirections.
   1048 To add a redirection, use:</p>
   1049 
   1050 <pre><code>add&nbsp;&lt;protocol&gt;:&lt;host-port&gt;:&lt;guest-port&gt;</code>
   1051 </pre>
   1052 
   1053 <p>where <code>&lt;protocol&gt;</code> is either <code>tcp</code> or <code>udp</code>, 
   1054 and <code>&lt;host-port&gt;</code> and <code>&lt;guest-port&gt;</code> sets the 
   1055 mapping between your own machine and the emulated system, respectively. </p>
   1056 
   1057 <p>For example, the following command sets up a redirection that will handle all
   1058 incoming TCP connections to your host (development) machine on 127.0.0.1:5000
   1059 and will pass them through to the emulated system's 10.0.2.15:6000.:</p>
   1060 
   1061 <pre>redir add tcp:5000:6000</pre>
   1062 
   1063 <p>To delete a redirection, you can use the <code>redir del</code> command. To
   1064 list all redirections for a specific instance, you can use <code>redir
   1065 list</code>. For more information about these and other console commands, see 
   1066 <a href="#console">Using the Emulator Console</a>. </p>
   1067 
   1068 <p>Note that port numbers are restricted by your local environment. this typically
   1069 means that you cannot use host port numbers under 1024 without special
   1070 administrator privileges.  Also, you won't be able to set up a redirection for a
   1071 host port that is already in use by another process on your machine. In that
   1072 case, <code>redir</code> generates an error message to that effect. </p>
   1073 
   1074 <a name="adbredir"></a>
   1075 <h4>Setting Up Redirections through ADB</h4>
   1076 
   1077 <p>The Android Debug Bridge (ADB) tool provides port forwarding, an alternate
   1078 way for you to set up network redirections. For more information, see <a
   1079 href="{@docRoot}guide/developing/tools/adb.html#forwardports">Forwarding Ports</a> in the ADB
   1080 documentation.</p>
   1081 
   1082 <p>Note that ADB does not currently offer any way to remove a redirection,
   1083 except by killing the ADB server.</p>
   1084 
   1085 <a name="dns"></a>
   1086 <h3>Configuring the Emulator's DNS Settings</h3>
   1087 
   1088 <p>At startup, the emulator reads the list of DNS servers that your system is
   1089 currently using. It then stores the IP addresses of up to four servers on this
   1090 list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4,
   1091 10.0.2.5 and 10.0.2.6 as needed.  </p>
   1092 
   1093 <p>On Linux and OS X, the emulator obtains the DNS server addresses by parsing 
   1094 the file <code>/etc/resolv.conf</code>. On Windows, the emulator obtains the 
   1095 addresses by calling the <code>GetNetworkParams()</code> API. Note that this 
   1096 usually means that the emulator ignores the content of your "hosts" file 
   1097 (<code>/etc/hosts</code> on Linux/OS X, <code>%WINDOWS%/system32/HOSTS</code>
   1098  on Windows).</P>
   1099 
   1100 <p>When starting the emulator at the command line, you can also use the
   1101 <code>-dns-server &lt;serverList&gt;</code> option to manually specify the
   1102 addresses of DNS servers to use, where &lt;serverList&gt; is a comma-separated
   1103 list of server names or IP addresses. You might find this option useful if you
   1104 encounter DNS resolution problems in the emulated network (for example, an
   1105 "Unknown Host error" message that appears when using the web browser).</p>
   1106 
   1107 <a name="proxy"></a>
   1108 <h3>Using the Emulator with a Proxy</h3>
   1109 
   1110 <p>If your emulator must access the Internet through a proxy server, you can use
   1111 the <code>-http-proxy &lt;proxy&gt;</code> option when starting the emulator, to
   1112 set up the appropriate redirection. In this case, you specify proxy information
   1113 in <code>&lt;proxy&gt;</code> in one of these formats:</p>
   1114 
   1115 <pre>http://<machineName>:<port>;</pre>
   1116 
   1117 <p>or</p>
   1118 
   1119 <pre>http://<username>:<password>@<machineName>:<port>;</pre>
   1120 
   1121 <p>The <code>-http-proxy</code> option forces the emulator to use the specified
   1122 HTTP/HTTPS proxy for all outgoing TCP connections. Redirection for UDP is not
   1123 currently supported.</p>
   1124 
   1125 <p>Alternatively, you can define the environment variable
   1126 <code>http_proxy</code> to the value you want to use for
   1127 <code>&lt;proxy&gt;</code>. In this case, you do not need to specify a value for
   1128 <code>&lt;proxy&gt;</code> in the <code>-http-proxy</code> command &mdash; the
   1129 emulator checks the value of the <code>http_proxy</code> environment variable at
   1130 startup and uses its value automatically, if defined. </p>
   1131 
   1132 <p>You can use the <code>-verbose-proxy</code> option to diagnose proxy
   1133 connection problems.</p>
   1134 
   1135 <a name="connecting"></a>
   1136 <h3>Interconnecting Emulator Instances</h3>
   1137 
   1138 <p>To allow one emulator instance to communicate with another, you must set up
   1139 the necessary network redirections as illustrated below. </p>
   1140 
   1141 <p>Assume that your environment is</p>
   1142 
   1143 <ul>
   1144   <li>A is you development machine</li>
   1145   <li>B is your first emulator instance, running on A</li>
   1146   <li>C is your second emulator instance, running on A too</li>
   1147 </ul>
   1148 
   1149 <p>and you want to run a server on B, to which C will connect, here is how you
   1150 could set it up: </p>
   1151 
   1152 <ol>
   1153   <li>Set up the server on B, listening to
   1154 <code>10.0.2.15:&lt;serverPort&gt;</code></li>
   1155   <li>On B's console, set up a redirection from
   1156 <code>A:localhost:&lt;localPort&gt;</code> to <code>
   1157 B:10.0.2.15:&lt;serverPort&gt;</code></li>
   1158   <li>On C, have the client connect to <code>10.0.2.2:&lt;localPort&gt;</code></li>
   1159 </ol>
   1160 
   1161 <p>For example, if you wanted to run an HTTP server, you can select
   1162 <code>&lt;serverPort&gt;</code> as 80 and <code>&lt;localPort&gt;</code> as
   1163 8080:</p>
   1164 
   1165 <ul>
   1166   <li>B listens on 10.0.2.15:80</li>
   1167   <li>On B's console, issue <code>redir add tcp:8080:80</code></li>
   1168   <li>C connects to 10.0.2.2:8080</li>
   1169 </ul>
   1170 
   1171 <a name="calling"></a>
   1172 <h3>Sending a Voice Call or SMS to Another Emulator Instance</h3>
   1173 
   1174 <p>The emulator automatically forwards simulated voice calls and SMS messages from one instance to another. To send a voice call or SMS, you use the dialer application and SMS application (if available) installed on one emulator </p>
   1175 
   1176 <p>To initiate a simulated voice call to another emulator instance:</p>
   1177 <ol>
   1178 <li>Launch the dialer application on the originating emulator instance.</li>
   1179 <li>As the number to dial, enter the console port number of the instance you'd like to call. You can determine
   1180   the console port number of the target instance by checking its window title, where the
   1181   console port number is reported as "Android Emulator (&lt;port&gt;). </li>
   1182 <li>Press "Dial". A new inbound call appears in the target emulator instance. </li>
   1183 </ol>
   1184 
   1185 <p>To send an SMS message to another emulator instance, launch the SMS application (if available). Specify the console port number of the target emulator instance as as the SMS address, enter the message text, and send the message. The message is delivered to the target emulator instance. </p>
   1186 
   1187 <p>You can also connect to an emulator instance's console to simulate an incoming voice call or SMS. For more information, see <a href="#telephony">Telephony Emulation</a> and <a href="#sms">SMS Emulation</a>.
   1188 
   1189 <a name="console"></a>
   1190 
   1191 <h2>Using the Emulator Console</h2>
   1192 
   1193 <p>Each running emulator instance includes a console facility that lets you dynamically query and control the simulated device environment. For example, you can use the console to dynamically manage port redirections and network characteristics and simulate telephony events. To access the console and enter commands, you use telnet to connect to the console's port number. </p>
   1194 <p>To connect to the console of any running emulator instance at any time, use this command: </p>
   1195 
   1196 <pre>telnet localhost &lt;console-port&gt;</pre>
   1197 
   1198 <p>An emulator instance 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 emulator instance running on a given machine uses console port 5554 and adb port 5555. Subsequent instances use port numbers increasing by two &mdash; for example, 5556/5557, 5558/5559, and so on. Up to 16 concurrent emulator instances can run a console facility. </p>
   1199 
   1200 <p>To connect to the emulator console, you must specify a valid console port. If multiple emulator instances are running, you need to determine the console port of the emulator instance you want to connect to. You can find the instance's console port listed in the title of the instance window. For example, here's the window title for an instance whose console port is 5554:</p>
   1201 
   1202 <p><code>Android Emulator (5554)</code></p>
   1203 
   1204 <p>Alternatively, you can use the <code>adb devices</code> command, which prints a list of running emulator instances and their console port numbers. For more information, see <a href="{@docRoot}guide/developing/tools/adb.html#devicestatus">Querying for Emulator/Device Instances</a> in the adb documentation.</p>
   1205 
   1206 <p class="note">Note: The emulator listens for connections on ports 5554-5587 and accepts connections only from localhost.</p>
   1207 
   1208 <p>Once you are connected to the console, you can then enter <code>help [command]</code> to see a list of console commands and learn about specific commands. </p>
   1209 
   1210 <p>To exit the console session, use <code>quit</code> or <code>exit</code>.</p>
   1211 
   1212 <p>The sections below describe the major functional areas of the console.</p>
   1213 
   1214 <a name="portredirection"></a>
   1215 
   1216 <h3>Port Redirection</h3>
   1217 <p>You can use the console to add and remove port redirections while the emulator is running. After connecting to the console, you can manage port redirections in this way:</p>
   1218 <pre>redir &lt;list|add|del&gt; </pre>
   1219 
   1220 <p>The <code>redir</code> command supports the subcommands listed in the table below. </p>
   1221 
   1222 <table>
   1223 <tr>
   1224   <th width="25%" >Subcommand
   1225   <th width="30%" >Description</th>
   1226   <th width="35%">Comments</th>
   1227 </tr>
   1228   
   1229   <tr>
   1230     <td><code>list</code></td>
   1231     <td>List the current port redirections.</td>
   1232   <td>&nbsp;</td>
   1233   </tr>
   1234 
   1235   
   1236 <tr>
   1237  <td><code>add&nbsp;&lt;protocol&gt;:&lt;host-port&gt;:&lt;guest-port&gt;</code></td>
   1238   <td>Add a new port redirection.</td>
   1239 <td><ul><li>&lt;protocol&gt; must be either &quot;tcp&quot; or &quot;udp&quot;</li>
   1240 <li>&lt;host-port&gt; is the port number to open on the host</li>
   1241 <li>&lt;guest-port&gt; is the port number to route data to on the emulator/device</li>
   1242 </ul></td>
   1243 </tr>
   1244 <tr>
   1245   <td><code>del &lt;protocol&gt;:&lt;host-port&gt;</code></td>
   1246   <td>Delete a port redirection.</td>
   1247 <td>See above for meanings of &lt;protocol&gt; and &lt;host-port&gt;.</td>
   1248 </tr>
   1249 </table>
   1250 
   1251 <a name="geo"></a>
   1252 <h3>Geo Location Provider Emulation</h3>
   1253 
   1254 <p>The console provides commands to let you set the geo position used by an emulator emulated device.
   1255 You can use the <code>geo</code> command to send a simple GPS fix to the emulator, without needing to
   1256 use NMEA 1083 formatting. The usage for the command is:</p>
   1257 
   1258 <pre>geo &lt;fix|nmea&gt;</pre>
   1259 
   1260 <p>The <code>geo</code> command supports the subcommands listed in the table below.</p>
   1261 
   1262 <table>
   1263 <tr>
   1264   <th width="25%" >Subcommand
   1265   <th width="30%" >Description</th>
   1266   <th width="35%">Comments</th>
   1267 </tr>
   1268   
   1269   <tr>
   1270     <td><code>fix &lt;longitude&gt; &lt;latitude&gt; [&lt;altitude&gt;]</code></td>
   1271     <td>Send a simple GPS fix to the emulator instance.</td>
   1272   <td>Specify longitude and latitude in decimal degrees. Specify altitude in meters.</td>
   1273   </tr>
   1274 <tr>
   1275   <td><code>nmea &lt;sentence&gt;</code></td>
   1276   <td>Send an NMEA 0183 sentence to the emulated device, as if it were sent from an emulated GPS modem.</td>
   1277 <td><code>&lt;sentence&gt;</code> must begin with '$GP'. Only '$GPGGA' and '$GPRCM' sentences are currently supported.</td>
   1278 </tr>
   1279 </table>
   1280 
   1281 <p>You can issue the <code>geo</code> command to fix the GPS location as soon as an emulator instance is running.
   1282 The emulator creates a mock location provider that sends it to GPS-aware applications as soon as they start and
   1283 register location listeners. Any application can query the location manager to obtain the current GPS fix for the
   1284 emulated device by calling:
   1285 
   1286 <pre>LocationManager.getLastKnownLocation("gps")</pre>
   1287 
   1288 <p>For more information about the Location Manager, see {@link android.location.LocationManager} and its methods.</p>
   1289 
   1290 <a name="events"></a>
   1291 <h3>Hardware Events Emulation</h3>
   1292 
   1293 <p>You can use the <code>event</code> command to send various events to the emulator.The usage for the command is: </p>
   1294 
   1295 <pre>event &lt;send|types|codes|text&gt;</pre>
   1296 
   1297 <p>The <code>event</code> command supports the subcommands listed in the table below. </p>
   1298 
   1299 <table>
   1300 <tr>
   1301   <th width="25%" >Subcommand
   1302   <th width="30%" >Description</th>
   1303   <th width="35%">Comments</th>
   1304 </tr>
   1305   
   1306   <tr>
   1307     <td><code>send &lt;type&gt;:&lt;code&gt;:&lt;value&gt; [...]</code></td>
   1308     <td>Send one or more events to the Android kernel. </td>
   1309   <td>You can use text names or integers for <code>&lt;type&gt;</code> and <code>&lt;value&gt;</code>.</td>
   1310   </tr>
   1311 <tr>
   1312   <td><code>types</code></td>
   1313   <td>List all <code>&lt;type&gt;</code> string aliases supported by the <code>event</code> subcommands.</td>
   1314 <td>&nbsp;</td>
   1315 </tr>
   1316 <tr>
   1317   <td><code>codes &lt;type&gt;</code></td>
   1318   <td>List all <code>&lt;codes&gt;</code> string aliases supported by the <code>event</code> 
   1319    subcommands for the specified <code>&lt;type&gt;</code>.</td>
   1320 <td>&nbsp;</td>
   1321 </tr>
   1322 <tr>
   1323   <td><code>event text &lt;message&gt;</code></td>
   1324   <td>Simulate keypresses to send the specified string of characters as a message,</td>
   1325 <td>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.</td>
   1326 </tr>
   1327 </table>
   1328 
   1329 <a name="power"></a>
   1330 <h3>Device Power Characteristics</h3>
   1331 
   1332 <p>You can use the <code>power</code> command to control the simulated power state of the emulator instance.The usage for the command is: </p>
   1333 
   1334 <pre>power &lt;display|ac|status|present|health|capacity&gt;</pre>
   1335 
   1336 <p>The <code>event</code> command supports the subcommands listed in the table below. </p>
   1337 
   1338 <table>
   1339 <tr>
   1340   <th width="25%" >Subcommand </th>
   1341   <th width="30%" >Description</th>
   1342   <th width="35%">Comments</th>
   1343 </tr>
   1344   
   1345   <tr>
   1346     <td><code>display</code></td>
   1347     <td>Display battery and charger state.</td>
   1348   <td>&nbsp;</td>
   1349   </tr>
   1350 <tr>
   1351   <td><code>ac &lt;on|off&gt;</code></td>
   1352   <td>Set AC charging state to on or off. </td>
   1353 <td>&nbsp;</td>
   1354 </tr>
   1355 <tr>
   1356   <td><code>status &lt;unknown|charging|discharging|not-charging|full&gt;</code></td>
   1357   <td>Change battery status as specified.</td>
   1358 <td>&nbsp;</td>
   1359 </tr>
   1360 
   1361 <tr>
   1362   <td><code>present &lt;true|false&gt;</code></td>
   1363   <td>Set battery presence state.</td>
   1364 <td>&nbsp;</td>
   1365 </tr>
   1366 <tr>
   1367   <td><code>health &lt;unknown|good|overheat|dead|overvoltage|failure&gt;</code></td>
   1368   <td>Set battery health state.</td>
   1369 <td>&nbsp;</td>
   1370 </tr>
   1371 <tr>
   1372   <td><code>power health &lt;percent&gt;</code></td>
   1373   <td>Set remaining battery capacity state (0-100).</td>
   1374 <td>&nbsp;</td>
   1375 </tr>
   1376 </table>
   1377 
   1378 <a name="netstatus"></a>
   1379 <h3>Network Status</h3>
   1380 
   1381 <p>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 <code>netstatus</code> command. Here's an example of the command and its output. </p>
   1382 
   1383 <pre>network status
   1384 </pre>
   1385 
   1386 <a name="netdelay"></a>
   1387 <h3>Network Delay Emulation</h3>
   1388 
   1389 <p>The emulator lets you simulate various network latency levels, so that you can test your application 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 dynamically, while the application is running in the emulator. </p>
   1390 <p>To set latency at emulator startup, use the  <code>-netdelay</code> emulator option with a supported <code>&lt;delay&gt;</code> value, as listed in the table below. Here are some examples:</p>
   1391 <pre>emulator -netdelay gprs
   1392 emulator -netdelay 40 100</pre>
   1393 
   1394 <p>To make dynamic changes to  network delay while the emulator is running, connect to the console and use the <code>netdelay</code> command with a supported <code>&lt;delay&gt;</code> value from the table below.  </p>
   1395 
   1396 <pre>network delay gprs</pre>
   1397 
   1398 <p>The format of network &lt;delay&gt; is one of the following (numbers are milliseconds):</p>
   1399 
   1400 <table style="clear:right;width:100%;">
   1401 <tr>
   1402   <th width="30%" >Value</th>
   1403   <th width="35%" >Description</th><th width="35%">Comments</th></tr>
   1404   
   1405   <tr><td><code>gprs</code></td><td>GPRS</td>
   1406   <td>(min 150, max 550)</td>
   1407   </tr>
   1408 
   1409 <tr><td><code>edge</code></td><td>EDGE/EGPRS</td>
   1410 <td>(min 80, max 400)</td>
   1411 </tr>
   1412 <tr><td><code>umts</code></td><td>UMTS/3G</td>
   1413 <td>(min 35, max 200)</td>
   1414 </tr>
   1415 <tr><td><code>none</code></td><td>No latency</td><td>(min 0, max 0)</td></tr>
   1416 <tr><td><code>&lt;num&gt;</code></td>
   1417 <td>Emulate an exact latency  (milliseconds).</td>
   1418 <td>&nbsp;</td></tr>
   1419 <tr><td><code>&lt;min&gt;:&lt;max&gt;</code></td>
   1420 <td>Emulate an specified latency range (min, max milliseconds).</td>
   1421 <td>&nbsp;</td></tr>
   1422 </table>
   1423 
   1424 <a name="netspeed"></a>
   1425 <h3>Network Speed Emulation</h3>
   1426 
   1427 <p>The emulator also lets you simulate various network transfer rates. 
   1428 You can set a transfer rate or range at emulator startup or you can use the console to change the rate dynamically,
   1429 while the application is running in the emulator.</p>
   1430 
   1431 <p>To set the network speed at emulator startup, use the  <code>-netspeed</code> emulator option with a supported
   1432 <code>&lt;speed&gt;</code> value, as listed in the table below. Here are some examples:</p>
   1433 <pre>emulator -netspeed gsm
   1434 emulator -netspeed 14.4 80</pre>
   1435 
   1436 <p>To make dynamic changes to  network speed while the emulator is running, connect to the console and use the <code>netspeed</code> command with a supported <code>&lt;speed&gt;</code> value from the table below.  </p>
   1437 
   1438 <pre>network speed 14.4 80</pre>
   1439 
   1440 <p>The format of network <code>&lt;speed&gt;</code> is one of the following (numbers are
   1441 kilobits/sec):</p>
   1442 <table style="clear:right;width:100%;">
   1443 <tbody>
   1444 <tr>
   1445   <th width="30%">Value</th>
   1446   <th width="35%">Description</th><th width="35%">Comments</th></tr>
   1447   
   1448   <tr>
   1449   <td><code>gsm</code></td>
   1450   <td>GSM/CSD</td><td>(Up: 14.4, down: 14.4)</td></tr>
   1451 <tr>
   1452   <td><code>hscsd</code></td>
   1453   <td>HSCSD</td><td>(Up: 14.4, down: 43.2)</td></tr>
   1454 <tr>
   1455   <td><code>gprs</code></td>
   1456   <td>GPRS</td><td>(Up: 40.0, down: 80.0)</td></tr>
   1457 <tr>
   1458   <td><code>edge</code></td>
   1459   <td>EDGE/EGPRS</td>
   1460   <td>(Up: 118.4, down: 236.8)</td>
   1461 </tr>
   1462 <tr>
   1463   <td><code>umts</code></td>
   1464   <td>UMTS/3G</td><td>(Up: 128.0, down: 1920.0)</td></tr>
   1465 <tr>
   1466   <td><code>hsdpa</code></td>
   1467   <td>HSDPA</td><td>(Up: 348.0, down: 14400.0)</td></tr>
   1468 <tr>
   1469   <td><code>full</code></td>
   1470   <td>no limit</td><td>(Up: 0.0, down: 0.0)</td></tr>
   1471 <tr>
   1472   <td><code>&lt;num&gt;</code></td>
   1473   <td>Set an exact rate used for both upload and download.</td><td></td></tr>
   1474 <tr>
   1475   <td><code>&lt;up&gt;:&lt;down&gt;</code></td>
   1476   <td>Set exact rates for upload and download separately.</td><td></td></tr>
   1477 </table>
   1478 
   1479 <a name="telephony"></a>
   1480 
   1481 <h3>Telephony Emulation</h3>
   1482 
   1483 <p>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 and establish/terminate data connections. The Android system handles simulated calls exactly as it would actual calls. The emulator does not support call audio in this release. </p>
   1484 <p>You can use the console to access the emulator's telephony functions. After connecting to the console, you can use</p>
   1485 <pre>gsm &lt;call|accept|busy|cancel|data|hold|list|voice|status&gt; </pre>
   1486 <p>to invoke telephony functions. </p>
   1487 <p>The <code>gsm</code> command supports the subcommands listed in the table below. </p>
   1488 <table>
   1489   <tr>
   1490     <th>Subcommand </th>
   1491     <th width="25%">Description</th>
   1492     <th>Comments</th>
   1493   </tr>
   1494   <tr>
   1495     <td><code>call &lt;phonenumber&gt;</code></td>
   1496     <td>Simulate an inbound phone call from &lt;phonenumber&gt;.</td>
   1497     <td>&nbsp;</td>
   1498   </tr>
   1499   <tr>
   1500     <td><code>accept &lt;phonenumber&gt;</code></td>
   1501     <td>Accept an inbound call from &lt;phonenumber&gt; and change the call's state "active".</td>
   1502     <td>You can change a call's state to "active" only if its current state is "waiting" or "held".</td>
   1503   </tr>
   1504   <tr>
   1505     <td><code>busy &lt;phonenumber&gt;</code></td>
   1506     <td>Close an outbound call to &lt;phonenumber&gt; and change the call's state to "busy".</td>
   1507     <td>You can change a call's state to "busy" only if its current state is "waiting".</td>
   1508   </tr>
   1509   <tr>
   1510     <td><code>cancel &lt;phonenumber&gt;</code></td>
   1511     <td>Terminate an inbound or outbound phone call to/from &lt;phonenumber&gt;.</td>
   1512     <td>&nbsp;</td>
   1513   </tr>
   1514   <tr>
   1515     <td><code>data &lt;state&gt;</code></td>
   1516     <td>Change the state of the GPRS data connection to &lt;state&gt;.</td>
   1517     <td>Supported &lt;state&gt; values are:<br />
   1518     <ul>
   1519           <li><code>unregistered</code> -- No network available</li>
   1520           <li><code>home</code> -- On local network, non-roaming</li>
   1521           <li><code>roaming</code> -- On roaming network</li>
   1522           <li><code>searching</code> -- Searching networks</li>
   1523           <li><code>denied</code> -- Emergency calls only</li>
   1524           <li><code>off</code> -- Same as 'unregistered'</li>
   1525       <li><code>on</code> -- same as 'home'</li>
   1526     </ul>
   1527           </td>
   1528   </tr>
   1529   <tr>
   1530     <td><code>hold</code></td>
   1531     <td>Change the state of a call to "held". </td>
   1532     <td>You can change a call's state to "held" only if its current state is	 "active" or "waiting". </td>
   1533   </tr>
   1534   <tr>
   1535     <td><code>list</code></td>
   1536     <td>List all inbound and outbound calls and their states.</td>
   1537     <td>&nbsp;</td>
   1538   </tr>
   1539   <tr>
   1540     <td><code>voice &lt;state&gt;</code></td>
   1541     <td>Change the state of the GPRS voice connection to &lt;state&gt;.</td>
   1542     <td>Supported &lt;state&gt; values are:<br />
   1543     <ul>
   1544     <li><code>unregistered</code> -- No network available</li>
   1545     <li><code>home</code> -- On local network, non-roaming</li>
   1546     <li><code>roaming</code> -- On roaming network</li>
   1547     <li><code>searching</code> -- Searching networks</li>
   1548     <li><code>denied</code> -- Emergency calls only</li>
   1549     <li><code>off</code> -- Same as 'unregistered'</li>
   1550     <li><code>on</code> -- Same as 'home'</li>
   1551     </ul>
   1552     </td>
   1553   </tr>
   1554 
   1555   <tr>
   1556     <td><code>status</code></td>
   1557     <td>Report the current GSM voice/data state.</td>
   1558     <td>Values are those described for the <code>voice</code> and <code>data</code> commands.</td>
   1559   </tr>
   1560 </table>
   1561 
   1562 <a name="sms"></a>
   1563 
   1564 <h3>SMS Emulation</h3>
   1565 
   1566 <p>The Android emulator console lets you generate an SMS message and direct it to an emulator instance. Once you connect to an emulator instance, you can generate an emulated incoming SMS using this command:</p>
   1567 
   1568 <pre>sms send &lt;senderPhoneNumber&gt; &lt;textmessage&gt;</pre>
   1569 
   1570 <p>where <code>&lt;senderPhoneNumber&gt;</code> contains an arbitrary numeric string. </p>
   1571 
   1572 <p>The console forwards the SMS message to the Android framework, which passes it through to an application that handles that message type. </p>
   1573 
   1574 <a name="vm"></a>
   1575 
   1576 <h3>VM State</h3>
   1577 
   1578 <p>You can use the <code>vm</code> command to control the VM on an emulator instance.The usage for the command is: </p>
   1579 
   1580 <pre>vm &lt;start|stop|status&gt;</pre>
   1581 
   1582 <p>The <code>vm</code> command supports the subcommands listed in the table below. </p>
   1583 
   1584 <table>
   1585 <tr>
   1586   <th width="25%" >Subcommand </th>
   1587   <th width="30%" >Description</th>
   1588   <th width="35%">Comments</th>
   1589 </tr>
   1590 <tr>
   1591     <td><code>start</code></td>
   1592     <td>Start the VM on the instance. </td>
   1593   <td>&nbsp;</td>
   1594 </tr>
   1595 <tr>
   1596     <td><code>stop</code></td>
   1597     <td>Stop the VM on the instance. </td>
   1598   <td>&nbsp;</td>
   1599 </tr>
   1600 <tr>
   1601     <td><code>start</code></td>
   1602     <td>Display the current status of the VM (running or stopped). </td>
   1603   <td>&nbsp;</td>
   1604 </tr>
   1605 </table>
   1606 
   1607 
   1608 <a name="window"></a>
   1609 
   1610 <h3>Emulator Window</h3>
   1611 
   1612 <p>You can use the <code>window</code> command to manage the emulator window. The usage for the command is: </p>
   1613 
   1614 <pre>window &lt;scale&gt;</pre>
   1615 
   1616 <p>The <code>vm</code> command supports the subcommands listed in the table below. </p>
   1617 
   1618 <table>
   1619 <tr>
   1620   <th width="25%" >Subcommand
   1621   <th width="30%" >Description</th>
   1622   <th width="35%">Comments</th>
   1623 </tr>
   1624 <tr>
   1625     <td><code>scale &lt;scale&gt;</code></td>
   1626     <td>Scale the emulator window.</td>
   1627   <td>&lt;scale&gt; must be a number between 0.1 and 3 that describes the desired scaling factor. You can 
   1628   also specify scale as a DPI value if you add the suffix "dpi" to the scale value. A value of "auto" 
   1629   tells the emulator to select the best window size.</td>
   1630 </tr>
   1631 </table>
   1632 
   1633 
   1634 <a name="terminating"></a>
   1635 
   1636 <h3>Terminating an Emulator Instance</h3>
   1637 
   1638 <p>You can terminate an emulator instance through the console, using the <code>kill</code> command.</p>
   1639 
   1640 
   1641 <a name="skins"></a>
   1642 
   1643 <h2>Using Emulator Skins</h2>
   1644 
   1645 <p>The Android SDK includes several Emulator skins that you can use to control the resolution and density of the emulated device's screen. To select a specific skin for running the emulator, create an AVD that uses that skin. Please do not use deprecated emulator options such as <code>-skin</code> to control the skin used by an emulator instance. For more information about AVDs, see <a
   1646 href="{@docRoot}guide/developing/devices/index.html">Managing Virtual Devices</a>.</p>
   1647 
   1648 
   1649 <a name="multipleinstances"></a>
   1650 
   1651 <h2>Running Multiple Emulator Instances</h2>
   1652 
   1653 <p>Through the AVDs configurations used by the emulator, you can run multiple
   1654 instances of the emulator concurrently, each with its own AVD configuration and
   1655 storage area for user data, SD card, and so on. You no longer need to use the
   1656 <code>-d</code> option when launching the emulator, to point to an
   1657 instance-specific storage area. </p>
   1658 
   1659 <a name="apps"></a>
   1660 
   1661 <h2>Installing Applications on the Emulator</h2>
   1662 
   1663 <p>If you don't have access to Eclipse or the ADT Plugin, you can install 
   1664 your application on the emulator <a href="{@docRoot}guide/developing/tools/adb.html#move">using 
   1665 the adb utility</a>. Before installing the application, you need to build and package it 
   1666 into an <code>.apk</code> as described in <a href="{@docRoot}guide/developing/building/index.html">Building and
   1667 Running Apps</a>. Once the application is installed, you can start the emulator from the command 
   1668 line, as described in this document, using any startup options necessary. 
   1669 When the emulator is running, you can also connect to the emulator instance's 
   1670 console to issue commands as needed.</p>
   1671 
   1672 <p>As you update your code, you periodically package and install it on the emulator. 
   1673 The emulator preserves the application and its state data across restarts, 
   1674 in a user-data disk partition. To ensure that the application runs properly 
   1675 as you update it, you may need to delete the emulator's user-data partition. 
   1676 To do so, start the emulator with the <code>-wipe-data</code> option. 
   1677 For more information about the user-data partition and other emulator storage, 
   1678 see <a href="#diskimages">Working with Emulator Disk Images</a>.</p>
   1679 
   1680 <a name="sdcard"></a>
   1681 <a name="creating"></a>
   1682 
   1683 <h2>SD Card Emulation</h2>
   1684 
   1685 <p>You can create a disk image and then load it to the emulator at startup, to
   1686 simulate the presence of a user's SD card in the device. To do this, you can use
   1687 the android tool to create a new SD card image with a new AVD, or you can use
   1688 the mksdcard utility included in the SDK. </p>
   1689 
   1690 <p>The sections below describe how to create an SD card disk image, how to copy
   1691 files to it, and how to load it in the emulator at startup. </p>
   1692 
   1693 <p>Note that you can only load disk image at emulator startup. Similarly, you
   1694 can not remove a simulated SD card from a running emulator. However, you can
   1695 browse, send files to, and copy/remove files from a simulated SD card either
   1696 with adb or the emulator. </p>
   1697 
   1698 <p>The emulator supports emulated SDHC cards, so you can create an SD card image
   1699 of any size up to 128 gigabytes.</p>
   1700 
   1701 <h3 id="creatinga">Creating an SD card image using the android tool</h3>
   1702 
   1703 <p>The easiest way to create a new SD card is to use the android tool. When
   1704 creating an AVD, you simply specify the <code>-c</code> option, like this: </p>
   1705 
   1706 <pre>android create avd -n &lt;avd_name&gt; -t &lt;targetID&gt; -c &lt;size&gt;[K|M]</pre>
   1707 
   1708 <p>You can also use the <code>-c</code> option to specify a path to an SD card
   1709 image to use in the new AVD. For more information, see <a
   1710 href="{@docRoot}guide/developing/devices/managing-avds-cmdline.html">Managing Virtual Devices
   1711 from the Command Line</a>.
   1712 </p>
   1713 
   1714 <h3 id="creatingm">Creating an SD card image using mksdcard</h3>
   1715 
   1716 <p>You can use the mksdcard tool, included in the SDK, to create a FAT32 disk
   1717 image that you can load in the emulator at startup. You can access mksdcard in
   1718 the tools/ directory of the SDK and create a disk image like this: </p>
   1719 
   1720 <pre>mksdcard &lt;size&gt; &lt;file&gt;</pre>
   1721 
   1722 <p>For example:</p>
   1723 
   1724 <pre>mksdcard 1024M sdcard1.iso</pre>
   1725 
   1726 <p>For more information, see <a href="{@docRoot}guide/developing/tools/mksdcard.html"><code>mksdcard</code></a>.</p>
   1727 
   1728 <a name="copying"></a>
   1729 <h3>Copying Files to a Disk Image</h3>
   1730 
   1731 <p>Once you have created the disk image, you can copy files to it prior to
   1732 loading it in the emulator. To copy files, you can mount the image as a loop
   1733 device and then copy the files to it, or you can use a utility such as mtools to
   1734 copy the files directly to the image. The mtools package is available for Linux,
   1735 Mac, and Windows.</p>
   1736 
   1737 <a name="loading"></a>
   1738 <a name="step3" id="step3"></a>
   1739 
   1740 <h3>Loading the Disk Image at Emulator Startup</h3>
   1741 
   1742 <p>By default, the emulator loads the SD card image that is stored with the active
   1743 AVD (see the <code>-avd</code> startup option).</p>
   1744 
   1745 <p>Alternatively, you ca start the emulator with the
   1746 <code>-sdcard</code> flag and specify the name and path of your image (relative
   1747 to the current working directory): </p>
   1748 
   1749 <pre>emulator -sdcard &lt;filepath&gt;</pre>
   1750 
   1751 <a name="troubleshooting"></a>
   1752 
   1753 <h2>Troubleshooting Emulator Problems</h2>
   1754 
   1755 <p>The adb utility sees the emulator as an actual physical device. For this reason, you might have to use the -d flag with some common adb commands, such as <code>install</code>. The -d flag lets you specify which of several connected devices to use as the target of a command. If you don't specify -d, the emulator will target the first device in its list. For more information about adb, see <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>.</p>
   1756 
   1757 <p>For emulators running on Mac OS X, if you see an error &quot;Warning: No DNS servers found&quot; when starting the emulator, check to see whether you have an <code>/etc/resolv.conf</code> file. If not, please run the following line in a command window:</p>
   1758     <pre>ln -s /private/var/run/resolv.conf /etc/resolv.conf</pre>
   1759 
   1760 <p>See <a href="{@docRoot}resources/faq/index.html">Frequently Asked Questions</a> for more troubleshooting information. </p>
   1761 
   1762 <a name="limitations"></a>
   1763     <h2>Emulator Limitations</h2>
   1764     <p>In this release, the  limitations of the emulator include: </p>
   1765     <ul>
   1766       <li>No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however. </li>
   1767       <li>No support for USB connections</li>
   1768       <li>No support for camera/video capture (input).</li>
   1769       <li>No support for device-attached headphones</li>
   1770       <li>No support for determining connected state</li>
   1771       <li>No support for determining battery charge level and AC charging state</li>
   1772       <li>No support for determining SD card insert/eject</li>
   1773       <li>No support for Bluetooth</li>
   1774     </ul>
   1775