Emulation Notes

According to Google, it is not possible to test the sensors using the emulator at all. Most computers don't have a light sensor, a GPS chip, or a compass built into them. Sure enough, if you run the SensorTest program in the emulator, it will display no results at all. However, a

® yaw 4 pitch] O roll & pitch O move

Socket | G 01 □

Set

Possible IP addresses: Listening on port 8010...

accelerometer: 0.ÜÜ, -3.03, -5.52

»

compass: 17.16,-26.05, -38.08

orientation: 828.00, -55.00: 0.00

Openlntents Sensor Simulator

Pitch l

Settings ±

Supported sensors

0 accelerometer 0 compass 0 orientation □ thermometer

Enabled sensors

0 accelerometer 0 compass

0 orientation T

Figure 8.2: Faking out the sensors with the Sensor Simulator project called OpenIntents5 provides an alternate sensor's API that you can call just for testing purposes.

The way it works is that you connect the emulator to another application running on your desktop computer called the Sensor Simulator. The simulator shows a picture of a virtual phone and lets you move it around on the screen with the mouse (see Figure 8.2), and then it feeds those movements to your Android program running on the emulator. If your development computer actually does have sensors of its own (like the Apple MacBook) or you can connect to a Wii remote with Bluetooth, the Sensor Simulator can use that as a data source.

The downside is that you have to modify your source code to make it work. See the OpenIntents website for more information if you want to try it. My recommendation is to forget about sensor emulation and get your hands on a real device. Keep tweaking your algorithms until it feels right.

5. http://www.openintents.org

Now that you know the low-level calls to get your location and query the sensors for numbers such as your compass heading, for certain applications you can forget all that and just use the Google Maps API.

0 0

Post a comment