14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: Maps, Geocoding, and Location-Based Services<br />

Figure 7-1<br />

Figure 7-1 shows the Manual and KML tabs. Using the Manual tab, you can specify particular latitude/<br />

longitude pairs. Alternatively, the KML and GPX tabs let you load KML (Keyhole Markup Language)<br />

and GPX (GPS Exchange Format) fi les, respectively. Once loaded, you can jump to particular waypoints<br />

(locations) or play back each location sequentially.<br />

Most GPS systems record track fi les using GPX, while KML is used extensively online to defi ne<br />

geographic information. You can handwrite your own KML fi le or generate one automatically using<br />

Google Earth and fi nding directions between two locations.<br />

All location changes applied using the DDMS Location Controls will be applied to the GPS receiver,<br />

which must be enabled and active. Note that the GPS values returned by getLastKnownLocation will<br />

not change unless at least one application has requested location updates.<br />

Create an <strong>Application</strong> to Manage Test Location Providers<br />

In this example, you’ll create a new project to set up the emulator to simplify testing other location-based<br />

applications. Running this project will ensure that the GPS provider is active and updating regularly.<br />

1. Create a new Android project, TestProviderController, which includes a<br />

TestProviderController Activity.<br />

package com.paad.testprovidercontroller;<br />

import java.util.List;<br />

import android.app.Activity;<br />

import android.content.Context;<br />

import android.location.Criteria;<br />

import android.location.Location;<br />

import android.location.LocationManager;<br />

import android.location.LocationListener;<br />

import android.location.LocationProvider;<br />

209

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!