2

I'm using flex 4.6 mobile application my issue when i get the current location using gps sensors it take alot of time Within the limits of 35 sec to take 2 updates my code is

            protected function GetGPSposition():void
        {
            //Initialize the location sensor.
            geo = new Geolocation();
            if(! geo.muted){  //gps is enabled
                geo = new Geolocation();
                geo.setRequestedUpdateInterval(10);
                geo.addEventListener(GeolocationEvent.UPDATE, handleLocationRequest);
                geo.addEventListener(StatusEvent.STATUS,handleErrorGPS);
            }
            else if(geo.muted){ //gps is disabled
                    (new GPS2()).open(this, false) ;
                    internetGpsEnable = false ;
                }
        }
            protected function handleLocationRequest(event:GeolocationEvent):void 
        { 

            counter++ ;
            if (counter > 1)
            {
                long = event.longitude;
                lat =  event.latitude;
                internetGpsEnable =true ;
                lblGPS.text = null;
            }
        }

Note : GetGPSposition() worked in creationComplete Can any one to advice me if any method to get the longitude and latitude fast as possible . Thanks in advance for help.

Sameh
  • 45
  • 7

1 Answers1

1

The GPS of an android device runs in an idle state until requested to save battery, once requested it takes time to communicate and calculate, you can't make this process faster.

If you have both fine and coarse position permissions the Geolocation API should report the Radio/GPRS location while the GPS resolves, but this isn't exact.

I believe your method is as fast as it is possible to go, short of calling into Geolocation when the app starts, to ensure its always polling.

CyanAngel
  • 1,240
  • 1
  • 14
  • 28