100% found this document useful (1 vote)
320 views

Android Emulator

The document discusses the Android emulator, which allows developers to test Android applications on a virtual mobile device running on their computer. It provides 3 key features: 1. It emulates the hardware and software of a typical Android phone, including ARM CPU, LCD display, keyboards, sound, and flash memory. 2. Developers can control the emulator using keyboard shortcuts to simulate actions like pressing buttons. 3. The emulator uses disk images containing system/data partitions to mimic the storage on an actual device.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
320 views

Android Emulator

The document discusses the Android emulator, which allows developers to test Android applications on a virtual mobile device running on their computer. It provides 3 key features: 1. It emulates the hardware and software of a typical Android phone, including ARM CPU, LCD display, keyboards, sound, and flash memory. 2. Developers can control the emulator using keyboard shortcuts to simulate actions like pressing buttons. 3. The emulator uses disk images containing system/data partitions to mimic the storage on an actual device.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Fundamentals of Mobile Programming

Android Basics
Environment Emulator Elo A. Ogardo
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.
Android Emulator v1.5 Skin
Status Bar – Notification Line

Power
Volume

Tab
Launch
Pad
Menu

Home Back

Call Hang up
Status Bar – Notification Line
Volume

Power

Call
Hang up

Home

Menu Back

Tab
Launch
Pad
Tab Status Bar – Notification Line
Launch Volume
Pad
Power

Call
Hang up

Home

Menu Back
Android Emulator Keyboard OS function
Escape Back button
Home Home button
F2, PageUp Menu (Soft-Left) button
Shift-F2, PageDown Start (Soft-Right) button
F3 Call/Dial button
Controlling the Android Emulator F4 Hangup / EndCall button
F5 Search button
through keyboard keys F7 Power button
Ctrl-F3, Ctrl-KEYPAD_5 Camera button
Keypad keys only work when Ctrl-F5, KEYPAD_PLUS Volume up button
Ctrl-F6, KEYPAD_MINUS Volume down button
NumLock is deactivated. KEYPAD_5 DPad center
KEYPAD_4 DPad left
KEYPAD_6 DPad right
KEYPAD_8 DPad up
KEYPAD_2 DPad down
F8 toggle cell network on/off
F9 toggle code profiling (when -trace option set)
Alt-ENTER toggle FullScreen mode
Ctrl-T toggle trackball mode
Ctrl-F11, KEYPAD_7 switch to previous layout
Ctrl-F12, KEYPAD_9 switch to next layout
Android Emulator

Features - Emulating First Generation Android Phones


The Android emulator supports many hardware features likely to be found on
mobile devices (such as the HTC-G1), including:

1. An ARMv5 CPU and the corresponding memory-management unit (MMU)


2. A 16-bit LCD display (mimicking 360 x 480 pixels)
3. One or more keyboards (a Qwerty-based keyboard and associated
Dpad/Phone buttons)
4. A sound chip with output and input capabilities
5. Flash memory partitions (emulated through disk image files on the
development machine)
6. A GSM modem, including a simulated SIM Card
Android Emulator
Nexus One (newer Google developer phone)

Some phones in the


market already
surpass these specs
(Fall 2010)
Android Emulator
Working with Emulator Disk Images
•The emulator uses mountable disk images (ANDROID SYSTEM IMAGE) stored on
your development machine to simulate flash (or similar) partitions on an actual
device.
For example, it uses disk images containing
(1) an emulator-specific kernel,
(2) the Android system,
(3) a ram-disk image, and
(4) writeable images for user data and simulated SD card.

By default, the Emulator always looks for the disk images in the
private storage area of the AVD in use (c:\android-sdk-
windows\platform\ … ) . .
Android Emulator
Working with Emulator Disk Images
If no platform images exist when the emulator is lunched, it creates
the image in the AVD directory based on default versions stored in
the SDL.

Note:
The default storage location for AVDs is in

~/.android/avd on OS X and Linux,


C:\Documents and Settings\<user>\.android\avd\... on
Windows XP, and
C:\Users\<user>\.android\ on Windows Vista.
C:\Documents and id: 5 or "android-7"
Settings\Administrator\.android\avd\AVD22GoogleAPI8.a Name: Android 2.1-update1
vd>a Type: Platform
Available Android targets: API level: 7
id: 1 or "android-3" Revision: 2
Creating an AVD using the Name: Android 1.5
Type: Platform
Skins: HVGA (default),
QVGA, WQVGA400,
android tool API level: 3
Revision: 4
WQVGA432,
WVGA800, WVGA854
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, id: 6 or "Google Inc.:Google APIs:7"
QVGA-P Name: Google APIs
id: 2 or "Google Inc.:Google APIs:3" Type: Add-On Vendor:
Listing targets Name: Google APIs Google Inc.
Type: Add-On Vendor: Revision: 1
To generate a list of system Google Inc. Description: Android +
Revision: 3 Google APIs
image targets, use this Description: Android + Google APIs Based on Android 2.1-update1 (API level 7)
Based on Android 1.5 (API level 3) Libraries:
command: Libraries: * com.google.android.maps
* com.google.android.maps (maps.jar) API for Google Maps
(maps.jar) API for Google Maps Skins: WVGA854, WQVGA400, HVGA
Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L, (default),
HVGA-P WQVGA432, WVGA800, QVGA
android list targets id: 3 or "android-4" id: 7 or "android-8"
Name: Android 1.6 Name: Android 2.2
Type: Platform Type: Platform
API level: 4 API level: 8
Revision: 3 Revision: 2
Skins: HVGA (default), Skins: HVGA
QVGA, WVGA800, (default), QVGA,
WVGA854 WQVGA400,
id: 4 or "Google Inc.:Google APIs:4" WQVGA432,
Name: Google APIs WVGA800,
Type: Add-On Vendor: WVGA854
Google Inc. id: 8 or "Google Inc.:Google APIs:8"
Revision: 2 Name: Google APIs
Description: Android + Google APIs Type: Add-On Vendor:
Based on Android 1.6 (API level 4) Google Inc.
Libraries: Revision: 2
* com.google.android.maps Description: Android + Google APIs
(maps.jar) API for Google Maps Based on Android 2.2 (API level 8) 11
Skins: WVGA854, HVGA (default), Libraries:
WVGA800, QVGA * com.google.android.maps
(maps.jar) API for Google Maps
Skins: WVGA854, WQVGA400, HVGA (default),
Starting – Stopping the Emulator
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 .


After a few seconds 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.

To stop an emulator instance, just close the emulator's window.

To list all available AVDs enter DOS command


android list avd
Android Emulator

AVD - Android Virtual Devices


Android Virtual Devices (AVDs) are configurations of emulator options that let
you better model an actual device.

Each AVD is made up of:


• A hardware profile. You can set options to define the hardware features of the virtual
device. For example, you can define whether the device has a camera, whether it uses
a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
• A mapping to a system image. You can define what version of the Android platform
will run on the virtual device. You can choose a version of the standard Android
platform or the system image packaged with an SDK add-on.
• Other options. You can specify the emulator skin you want to use with the AVD, which
lets you control the screen dimensions, appearance, and so on. You can also specify
the emulated SD card to use with the AVD.
• A dedicated storage area on your development machine, in which is stored the device's
user data (installed applications, settings, and so on) and emulated SD card.
Android Emulator

AVD -Android Virtual Devices


You can create as many AVDs as you need, based on the types of devices
you want to model and the Android platforms and external libraries you
want to run your application on.
Android Emulator
Creating an AVD using the Eclipse-ADT Tool
From Eclipse, follow the sequence: Main menu (AVD Manager )
> Virtual Devices > New >

Provide a Name,
choose an Android target,
create a new SD card with about
2Gb, choose a screen type,
add hardware devices…

Click on: Create AVD


(wait, it takes several minutes
to format the new SD card)
Creating an AVD using the android tool
When creating an AVD, you simply specify the -c option, like this:

android create avd -n <avd_name> -t <targetID> -c <size>[K|M]

The –t (target) argument sets up a mapping between the AVD and the system image
that you want to use whenever the AVD is invoked. Later, when applications use the
AVD, they'll be running on the system that you specify in the -t argument.

To specify the system image to use, you refer to its target ID — an integer — as
assigned by the android tool. The target ID is not derived from the system image name,
version, or API Level, or other attribute, so you need to have the android tool list the
available system images and the target ID of each, as described in the next section. You
should do this before you run the android create avd command.
Example: Creating an AVD using the android tool

After listing all targets (see previous image) we have decided to make a
profile based on target id:4 to support SDK1.6 with Google API
Mapping libraries. It should also include a 1Gig SD card. We enter the
command

android create avd -n myAVD4SD1G -t 4 -c 1024M


Android Emulator
Example: Creating an AVD using the android tool

Verifying what AVDs are available in the system:


Android Emulator
SD Card Emulation
• You can create a disk image and then load it to the emulator at startup,
to simulate the presence of a user's SD card in the device.
• The emulator supports emulated SDHC cards, so you can create an SD card
image of any size up to 128 gigabytes.
• You can browse, send files to, and copy/remove files from a simulated SD
card either with adb or the emulator.

Creating an SD card image using mksdcard


Use the mksdcard tool, included in the SDK, to create a FAT32 disk images.

mksdcard <size> <file>


For example:
mksdcard 1024M c:/temp/mysdcard.iso
Android Emulator
Android Emulator – How to use the SDCARD device
The general syntax to create an SD card is

mksdcard [ -l label ] <size> <file>


• The tool mksdcard is part of the Android SDK. The SD label is optional.
• The device’s size is expressed as an integer number followed by either
K
(kilobytes) or M (megabytes).

Example: Create a 1GB SDcard


device using the following command
mksdcard 1024M
c:\mysdcard.img

Run the emulator with the


command
emulator -sdcard
c:\mysdcard.img
Moving Data, Music and Pictures to the Sdcard

1. Use the program ddms to push files into the SDcard (the emulator must
be running with the SD card attached to it).

2. Click on: Device > File Explorer, this will open a new window and there you will
select the SDcard.

3. Now you move data to the sdcard. Your options are

• Open a Windows Explore panel to drag & drop files/folders on the card, or

• Press on the button "Push File onto Device"


(see upper left icons: push, pull, delete).

( DDMS stands for Dalvik Debug Monitor Services. The program is located in the /tools folder of the SDK. Also available
in Eclipse perspective – Top upper right icons)
References
 http://developer.android.com/index.html

 http://developer.android.com/guide/developing/tools/emulator.html
END
Thank you!

You might also like