O'Reilly logo

Developing Android Applications with Adobe AIR by Véronique Brossier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Geolocation

Without geography, you’re nowhere.

Jimmy Buffett

The ability to locate exactly where you are on Earth via consumer products has become commonplace, yet the technology is empowering. If you own a GPS-capable cellular phone, you have this technology at your fingertips.

In this chapter, we will discuss the geolocation API for accessing location information from an Android device.

Geolocation Classes

The flash.events.GeolocationEvent class is a new Event object that contains updated geolocation information. The new flash.sensors.Geolocation class is a subclass of the EventDispatcher class. It listens for and receives information from the device’s location sensor in the form of a GeolocationEvent.

To use the geolocation classes, first you must add the necessary permissions. In Flash Professional, enable ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION device permissions under FileAIR Android SettingsPermissions. In Flash Builder, select ACCESS_NETWORK_STATE and ACCESS_WIFI_STATE under Mobile SettingsPermissions. To make changes, append your application manifest file as follows:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Fine location refers to GPS communication, while coarse location refers to network communication. I will explain the difference between the two later in this chapter.

Note

If your location permissions are not set up, your application will fail ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required