Occupy GPS resource on iOS (using Geolocation Class, Adobe AIR)
I am developing iOS app by Adobe AIR.
I found that if use Geolocation class in iOS platform, it would occupy GPS resource and other apps could not use GPS feature.
Does anyone find the same thing?
I'm not sure that it's my wrong codes or a bug of Adobe AIR.
Followings are my codes:
private var geolocation:Geolocation;
private开发者_StackOverflow中文版 function geolocationGet():void{
geolocation = new Geolocation();
geolocation.setRequestedUpdateInterval(100);
geolocation.addEventListener(GeolocationEvent.UPDATE, geoUpdateHandler);
}
private function geoUpdateHandler(e:GeolocationEvent):void{
geolocation.removeEventListener(GeolocationEvent.UPDATE, geoUpdateHandler);
trace("latitude: "+e.latitude+", longitude: "+e.longitude);
}
it's probably because you're hogging the gps by making requests too often. it's probably not even being able to cope with the first response, so everything is getting clogged up. change the setRequestedUpdateInterval to something like 3000 rather than 100 milliseconds cos it should work.
精彩评论