IT tutorials
 
Mobile
 

BlackBerry Tablet Applications : Exploring the APIs - GPS

12/18/2012 6:01:47 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

GPS stands for Global Positioning System. GPS is a space-based satellite navigation system that sends reliable location information to your handheld device.

If your application requires the use of the device’s GPS capabilities, you will need to select the read_geolocation permission when creating your project. 

Let’s review the code that follows. First, you’ll notice that there is a private variable named geoLocation declared of type flash.sensors.GeoLocation. Within applicationComplete of the application, an event handler function is called; it first checks to see if the device has an available GPS unit by reading the static property of the GeoLocation class. If this property returns as true, a new instance of GeoLocation is created and the data refresh interval is set to 500 milliseconds (.5 seconds) within the setRequestedUpdateInterval method, and an event listener of type GeoLocationEvent.UPDATE is added to handle updates. Upon update, the GPS information is read from the event and written to a TextArea within the handleUpdate function. Note that there is also some math being done to convert the speed property into miles per hour and kilometers per hour. The results can be seen within Figure 1.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               applicationComplete="application1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            import flash.sensors.Geolocation;

            private var geoLocation:Geolocation;

            protected function application1_applicationCompleteHandler
            (event:FlexEvent):void {
                if(Geolocation.isSupported==true){
                    geoLocation = new Geolocation();
                    geoLocation.setRequestedUpdateInterval(500);
                    geoLocation.addEventListener(GeolocationEvent.UPDATE, 
                    handleLocationRequest);
                } else {
                    status.text = "Geolocation feature not supported";
                }
            }

            private function handleLocationRequest(event:GeolocationEvent):void {
                var mph:Number = event.speed*2.23693629;
                var kph:Number = event.speed*3.6;
                info.text = "Updated: " + new Date().toTimeString() + "\n\n"
                    + "latitude: " + event.latitude.toString() + "\n"
                    + "longitude: " + event.longitude.toString() + "\n"
                    + "altitude: " + event.altitude.toString()  + "\n"
                    + "speed: " + event.speed.toString()  + "\n"
                    + "speed: " + mph.toString()  + " MPH \n"
                    + "speed: " + kph.toString()  + " KPH \n"
                    + "heading: " + event.heading.toString()  + "\n"
                    + "horizontal accuracy: "
                    + event.horizontalAccuracy.toString()  + "\n"
                    + "vertical accuracy: "
                    + event.verticalAccuracy.toString();
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Label id="status" text="Geolocation Info" top="10" width="100%" 
textAlign="center"/>
    <s:TextArea id="info" width="100%" top="40" editable="false"/>
</s:Application>

					  

Figure 1. GPS Information

 
Others
 
- BlackBerry Tablet Applications : Exploring the APIs - Accelerometer
- iPhone Developer : Working with View Controllers - Remembering Tab State
- iPhone Developer : Working with View Controllers - Tab Bars
- iPhone Developer : Working with View Controllers - Presenting a Custom Modal Information View
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 3) - Using Touch
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 2) - Debugging in the Emulator, Debugging with a Device
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 1) - Working with Events
- Windows Phone 8 : Designing with Blend
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 2) - Implementing the Location Manager Delegate
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 1)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us