Providing Mock Location Data


Build your own Android App Dev Empire

Get Instant Access

When testing your application on the Android emulator, there are a couple different ways to send it some mock location data: you can use the DDMS tool or the "geo" command option in the emulator console.

Using DDMS

With the DDMS tool, you can simulate location data a few different ways:

• Manually send individual longitude/latitude coordinates to the device.

• Use a GPX file describing a route for playback to the device.

• Use a KML file describing individual placemarks for sequenced playback to the device. For more information on using DDMS to spoof location data, see the Using DDMS guide.

Using the "geo" command in the emulator console

Launch your application in the Android emulator and open a terminal/console in your SDK's /tools directory. Connect to the emulator console. Now you can use:

• geo fix to send a fixed geo-location.

This command accepts a longitude and latitude in decimal degrees, and an optional altitude in meters. For example:

geo fix -121.45356 46.51119 4392

• geo nmea to send an NMEA 0183 sentence.

This command accepts a single NMEA sentence of type '$GPGGA' (fix data) or '$GPRMC' (transit data). For example:

geo nmea $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62

For information about how to connect to the emulator console, see Using the Emulator Console.

Was this article helpful?

0 0

Post a comment