O'Reilly logo

Flash Development for Android Cookbook by Joseph Labrecque

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

Detecting whether or not a device supports a geolocation sensor

When developing projects which target the Android operating system, it is always a good idea to make sure that certain sensors, such as the geolocation sensor, are actually supported on the device. In the case of an Android device, this will probably always be the case, but we should never assume the capabilities of any device.

How to do it...

We will need to use internal classes to detect whether or not the geolocation API is supported:

  1. First, import the following classes into your project:
    import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.Stage; import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFormat; import flash.sensors.Geolocation; ...

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