Saturday, June 3, 2023

Providing GPS Coordinates Via the Eclipse Android Simulator

In most Android devices, your location-based or map applications can determine the current geolocation using either GPS (Global Positioning System), cell tower triangulation, or wifi networks. With regards to GPS, Eclipse provides a tool to simulate coordinates in a way that mimics real-life usage. It’s called the GPS Emulator Control. The tool features a Dalvik Debug Monitor Server (DDMS) that can be utilized to send your device or emulator a mock location, which is useful for testing different aspects of your application’s location specific features without physically moving. In today’s article, we’re going to learn how to utilize the Emulator Control to provide GPS coordinates to your Android device or the built-in simulator using several different methods.

Geo Positioning in Eclipse

The android.location package contains the classes required to determine the current geo position. To use them, all you need to do is integrate and import the GPS modules in your application:

The DDMS debugging tool comes fully integrated into the Android Development Tools (ADT) plugin for Eclipse. It provides a lot of functionality, including port-forwarding services, screen capture on the device, thread and heap usage of processes, memory allocation of objects, emulation of device’s file system, incoming call and SMS spoofing, and last but not least, location data spoofing. It’s located in the “tools/” directory of the SDK. DDMS works with both the emulator and a connected device. If both are connected and running simultaneously, DDMS defaults to the emulator.

Eclipse’s Emulator Control Panel contains location controls for each type. To open it, click Window > Open Perspective > Other… > DDMS from the Eclipse menu.

It supports the following three geolocation data types:

  • Manual: For setting the location manually by specifying longitude and latitude values.
  • GPX: GPS eXchange file
  • KML: Keyhole Markup Language file


Obtaining Latitude and Longitude Data For Manual Entry

You can get latitude and longitude numbers from websites such as Get Lat Lon. All you have to do is zoom the map to the location you want and line it up in the center cross hairs. Here’s centre-town Ottawa below:


You can then copy & paste the coordinates into the Eclipse Location Control and send them to your device or emulator.

Using GPX

GPX – also known as the GPS Exchange Format – is a light-weight, open source XML data format for the interchange of GPS data between applications and Web services over the Internet. It can be used to describe waypoints, tracks, and routes as well as store location, elevation, and time. Programs that support GPX allow users to view their tracks, project their tracks on satellite images or other maps, annotate maps, and tag photographs with the geolocation in the Exif metadata.

<?xml version="1.0"?>
     creator="ExpertGPS 1.1 -" version="1.0">
     <bounds maxlon="-71.102973" maxlat="42.468655" minlon="-71.126602" minlat="42.401051"/>
     <wpt lon="-71.119277" lat="42.438878">
     <wpt lon="-71.119689" lat="42.439227">
     <wpt lon="-71.116146" lat="42.438917">
             <![CDATA[Bike Loop Bellevue]]>
         <rtept lon="-71.109942" lat="42.434980">
                 <![CDATA[Panther Cave]]>
         <rtept lon="-71.109236" lat="42.431240">
                 <![CDATA[Gate 6]]>
                 <![CDATA[Trail Head]]>

To use GPX in Eclipse:

  1. Switch to DDMS view.
  2. Find the Location Controls in the Emulator Control tab.
  3. Click the GPX tab and click Load GPX.
  4. Locate and select the GPX file.
  5. Click Play to begin sending coordinates to the Emulator.

Using KML

KML is a file format used to display geographic data in an Earth browser, such as Google Earth, Google Maps, and Google Maps for mobile. You can create KML files to pinpoint locations, add image overlays, and display rich data. KML is an international standard maintained by the Open Geospatial Consortium, Inc. (OGC).

A Placemark is one of the most commonly used features in Google Earth. It marks a position on the Earth’s surface, using a yellow pushpin as the icon. The simplest Placemark includes only aelement, which specifies the location of the Placemark. You can specify a name and a custom icon for the Placemark, and you can also add other geometry elements to it.

There are three different types of placemark: simple, floating, and extruded. The KML code for a simple placemark looks as follows:


Making your Android apps location-aware can really add a lot of punch to them. It’s worth knowing how to test them properly – a process which is both fairly straight forward and crucial to the smooth operation of your applications.

Rob Gravelle
Rob Gravelle
Rob Gravelle resides in Ottawa, Canada, and has been an IT guru for over 20 years. In that time, Rob has built systems for intelligence-related organizations such as Canada Border Services and various commercial businesses. In his spare time, Rob has become an accomplished music artist with several CDs and digital releases to his credit.

Popular Articles