Monday 23 May 2011

Android Emulator


The Android SDK includes a mobile device emulator -- a virtual mobile device that runs on your computer. The emulator lets you prototype, develop, and test Android applications without using a physical device.

The Android emulator mimics all of the hardware and software features of a typical mobile device, except that it can not receive or place actual phone calls. It provides a variety of navigation and control keys, which you can "press" using your mouse or keyboard to generate events for your application. It also provides a screen in which your application is displayed, together with any other Android applications running.



To let you model and test your application more easily, the emulator supports Android Virtual Device (AVD) configurations. AVDs let you specify the Android platform that you want to run on the emulator, as well as the hardware options and emulator skin files tht you want to use. Once your application is running on the emulator, it can use the services of the Android platform to invoke other applications, access the network, play audio and video, store and retrieve data, notify the user, and render graphical transitions and themes.

The emulator also includes a variety of debug capabilities, such as a console from which you can log kernel output, simulate application interrupts (such as arriving SMS messages or phone calls), and simulate latency effects and dropouts on the data channel.


Download the Android SDK:


Starting and Stopping the Emulator

During development and testing of your application, you install and run your application in the Android emulator. You can launch the emulator as a standalone application, from a command line, or you can use it as part of your Eclipse development environment. In either case, you specify the AVD configuration to load and any startup options you want to use, as described in this document.You can run your application on a single instance of the emulator or, depending on your needs, you can start multiple emulator instances and run your application in more than one emulated device. You can use the emulator's built-in commands to simulate GSM phone calling or SMS between emulator instances, and you can set up network redirections that allow emulators to send data to one another. For more information, see Telephony Emulation, SMS Emulation, and Emulator Networking
To start an instance of the emulator from the command line, change to the tools/ folder of the SDK.

 Enter emulator command like this:

emulator -avd <avd_name>

This initializes the emulator and loads an AVD configuration (see the next section for more information about AVDs). You will see the emulator window appear on your screen.
If you are working in Eclipse, the ADT plugin for Eclipse installs your application and starts the emulator automatically, when you run or debug the application. You can specify emulator startup options in the Run/Debug dialog, in the Target tab. When the emulator is running, you can issue console commands as described later in this document.
If you are not working in Eclipse, see Installing Applications on the Emulator for information about how to install your application.
To stop an emulator instance, just close the emulator's window.


Android Virtual Devices and the Emulator

To use the emulator, you first must create one or more AVD configurations. In each configuration, you specify an Android platform to run in the emulator and the set of hardware options and emulator skin you want to use. Then, when you launch the emulator, you specify the AVD configuration that you want to load.
To specify the AVD you want to load when starting the emulator, you use the -avd argument, as shown in the previous section.
Each AVD functions as an independent device, with its own private storage for user data, SD card, and so on. When you launch the emulator with an AVD configuration, it automatically loads the user data and SD card data from the AVD directory. By default, the emulator stores the user data, SD card data, and cache in the AVD directory.
To create and manage AVDs you use the android tool, a command-line utility included in the SDK. For complete information about how to set up AVDs, see Android Virtual Devices


Controlling the Emulator

You can use emulator startup options and console commands to control the behaviors and characteristics of the emulated environment itself.
When the emulator is running, you can interact with the emulated mobile device just as you would an actual mobile device, except that you use your mouse pointer to "touch" the touch screen and your keyboard keys to "press" the simulated device keys.
The table below summarizes the mappings between the emulator keys and and the keys of your keyboard.

Emulated Device Key
Keyboard Key
Home
HOME
Menu (left softkey)
F2 or Page-up button
Star (right softkey)
Shift-F2 or Page Down
Back
ESC
Call/dial button
F3
Hangup/end call button
F4
Search
F5
Power button
F7
Audio volume up button
KEYPAD_PLUS, Ctrl-5
Audio volume down button
KEYPAD_MINUS, Ctrl-F6
Camera button
Ctrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for example, portrait, landscape)
KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape)
KEYPAD_9, Ctrl-F12
Toggle cell networking on/off
F8
Toggle code profiling
F9 (only with -trace startup option)
Toggle full screen mode
Alt-Enter
Toggle trackball mode
F6
Enter trackball mode temporarily (while key is pressed)
Delete
DPad left/up/right/down
KEYPAD_4/8/6/2
DPad center click
KEYPAD_5
Onion alpha increase/decrease
KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)

Note that, to use keypad keys, you must first disable NumLock on your development computer.



Emulator Limitations

In this release, the limitations of the emulator include:

  • No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.
  • No support for USB connections
  • No support for camera/video capture (input).
  • No support for device-attached headphones
  • No support for determining connected state
  • No support for determining battery charge level and AC charging state
  • No support for determining SD card insert/eject
  • No support for Bluetooth

  



No comments:

Post a Comment