The Android Emulator

The Android emulator, included in the Android SDK, allows you to run Android apps in a simulated environment within Windows, Mac OS X or Linux, without using an actual Android device. The emulator displays a realistic Android user-interface window. It’s particularly useful if you do not have access to Android devices for testing. You should certainly test your apps on a variety of Android devices before uploading them to Google Play.

Before running an app in the emulator, you’ll need to create an Android Virtual Device (AVD), which defines the characteristics of the device on which you want to test, including the hardware, system image, screen size, data storage and more. If you want to test your apps for multiple Android devices, you’ll need to create separate AVDs to emulate each unique device, or use a service (like testdroid.com or appthwack.com) that enables you to test on many different devices.

We used the emulator (not an actual Android device) to take most but not all of the Android screen shots for this book. You can reproduce on the emulator most of the Android gestures (Fig. 1.11) and controls (Fig. 1.12) using your computer’s keyboard and mouse. The gestures on the emulator are a bit limited, since your computer probably cannot simulate all the Android hardware features. For example, to test GPS apps in the emulator, you’ll need to create files that simulate GPS readings. Also, although you can simulate orientation changes (to portrait or landscape mode), simulating particular accelerometer readings (the accelerometer allows the device to respond to up/down, left/right and forward/backward acceleration) requires features that are not built into the emulator. There is a Sensor Simulator available at

Image

Fig. 1.11 | Android gestures on the emulator.

Image

Fig. 1.12 | Android hardware controls on the emulator (for additional controls, go to http://developer.android.com/tools/help/emulator.html).

that you can use to send simulated sensor information into an AVD to test other sensor features in your apps. Figure 1.13 lists Android functionality that’s not available on the emulator. You can, however, upload your app to an Android device to test these features. You’ll start creating AVDs and using the emulator to develop Android apps in Chapter 2’s Welcome app.

Android functionality not available on the emulator

• Making or receiving real phone calls (the emulator allows simulated calls only)

• Bluetooth

• USB connections

• Device-attached headphones

• Determining connected state of the phone

• Determining battery charge or power charging state

• Determining SD card insert/eject

• Sensors (accelerometer, barometer, compass, light sensor, proximity sensor)

Fig. 1.13 | Android functionality not available on the emulator (http://developer.android.com/tools/devices/emulator.html).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.164.246