GPS is a native extensionÂ to use the geographical location information of a device. It is able to read Â time,Â geographical locationÂ and the deviceâ€™s last location information.Â When the location of the device changes, the application can receive updates about the changes too. All of the needed geographical location data (time, accuracy, latitude, longitude, altitude, speed, provider and bearing ) can be extracted in the form of an Object.
Even though Adobe AIR already has aÂ Geolocation API,Â the extension has even more features, such asÂ access to location menu,Â checking the GPS status ( Is it on or off),Â enabling/disabling listeners,Â checking GPS availability Â andÂ the device GPS support.
var _ex:Gps; // initialize the extension _ex = new Gps(); // This listener tells you that the location menu has been closed. _ex.addEventListener(GpsEvent.LOCATION_MENU_CLOSED, closed); // This listener informs you when new location data is gained. _ex.addEventListener(GpsEvent.UPDATE_STATUS, location); // This listener informs you when the GPS is temporarily unavailable. _ex.addEventListener(GpsEvent.GPS_TEMPORARILY_UNAVAILABLE, unavailable); // This listener infors you when the device GPS has been activated. _ex.addEventListener(GpsEvent.GPS_ENABLE, enable); // This listener informs you when the device GPS has been deactivated. _ex.addEventListener(GpsEvent.GPS_DISABLE, disable); // If you want to find out whether the device supports GPS or not you can use the isSupported property. var Support:boolean = _ex.isSupported; trace("is Supported >> " + support); // If you want to find out whether the GPS is active or not you can use the isGpsEnabled property. var Enable:boolean = _ex.isGpsEnabled; trace("isGpsEnabled >>" + Enable); // In order to have access to the GPS location menu you can use the openLocationMenu() function. _ex.openLocationMenu();