RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


You Are Here: Using GPS and Google Maps in Android : Page 2

In the next installment of this Android series, you'll learn how to incorporate GPS and Google Maps into your Android application, so your users can see where they are, all the time.


Testing GPS Functionalities

The DDMS tool in the Android plug-in for Eclipse allows you to test GPS functionality very easily. In Eclipse, switch to the DDMS view and locate the Location Controls section in the Emulator Control tab (see Figure 1).

Figure 1. The Location Controls Section: This section allows you to test GPS functionality on the Android emulator.
Figure 2. The New Location Information: When the GPS data is received, the application displays the latitude and longitude obtained.

There are three separate tabs in the Location Controls section. First, you can manually send in the coordinates by specifying the latitude and longitude. When the GPS data is received on the Android emulator, the application will display the latitude and longitude obtained (see Figure 2).

Another way to send in geographical locations is to use a .GPX file. GPX (GPS Exchange Format) is a light-weight XML data format for interchange of GPS data. You can download GPS samples here. Once a .GPX file is downloaded, click the Load GPX… button to load the .GPX file (see Figure 3).

You can click the Play button to send a series of coordinates to the Android emulator at regular time intervals. The Android Eclipse plug-in also supports KML (Keyhole Markup Language) files. You can download a sample .KML file here. Like the .GPX file, you can also send a series of coordinates to the Android emulator by clicking on the Play button (see Figure 4).

Figure 3. Loading a .GPX File: Click the Load GPX button to load the .GPX file.
Figure 4. Loading a .KML File: Sending coordinates to the .KML file.

If you don't use Eclipse, you can also telnet to the Android emulator and use the geo command to send GPS coordinates to the emulator:

C:\>telnet localhost 5554
Android Console: type 'help' for a list of commands
geo fix -82.411629 28.054553
The geo command also allows you to send NMEA data sentences, like this:

geo nmea $GPGGA,001431.092,0118.2653,N,10351.1359,E,0,00,,-19.6,M,4.1,M,,0000*5B

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date