Chapter 8. Simulating Events

There are a variety of occurrences you will want to test that are difficult to replicate as they would happen in real life. In these cases, tools are available that will allow you to simulate events so you can test effectively.

Simulating Location and Routes

For instance, testing location can be challenging. It is impractical or impossible to travel to remote locations or simulate the exact same track over and over again. Fortunately, the DDMS tool provides a way to specify a location you would like your emulator to simulate (as latitude/longitude coordinates), or a path you would like to simulate (in the form of GPX or KML).

To simulate location, you need to open the DDMS tool (see Launching the DDMS Perspective). To launch the Eclipse perspective, select:WindowOpen Perspective...Other...DDMSOK.

Next, open the Emulator Control tab (which looks like Figure 8-1). In this tab, you can see a section marked Location Controls, where you can enter location attributes. When you are done entering your personalized data, hit the Send, Load GPX, or Load KML button (depending on which type of data you are working with). This causes your emulator to simulate the location you specified.

Simulating location with the emulator
Figure 8-1. Simulating location with the emulator

The following steps demonstrate how to simulate a particular location on your device. The same process can be used to simulate ...

Get Android Developer Tools Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.