Checking Internet connectivity in AIR application

19 views
Skip to first unread message

sheetal

unread,
Dec 16, 2009, 5:52:09 AM12/16/09
to Flex India Community
Hi All,
How to check internet connected or not in AIR app.
Event.NETWORK_CHANGE only tells the change in the status,but it dosent
tell if it is disabled or enabled.
Please share if anything else can tell if internet is available.


-Sheetal.

riaflexible

unread,
Dec 16, 2009, 7:16:41 AM12/16/09
to Flex India Community
Sheetal :

Try this , Might be useful , This is how i do to check the Internet
connectivity .

Event :

networkChange="networkChangeHandler(event)"

private function networkChangeHandler(event:Event):void {
checkConnectionStatus();
}

private function checkConnectionStatus():void {
var urlReq:URLRequest = new URLRequest("www.google.com");
var loader:URLLoader = new URLLoader();
loader.load(urlReq);
loader.addEventListener(Event.COMPLETE,onConnectionStatusResult);
loader.addEventListener
(IOErrorEvent.IO_ERROR,onConnectionStatusFault);
}

private function onConnectionStatusResult(event:Event):void {
Alert.show("online");
}

private function onConnectionStatusFault(event:Event):void {
Alert.show("offline");
}

Thanks,
Satish

sheetal

unread,
Dec 17, 2009, 12:10:11 AM12/17/09
to Flex India Community
Hey,thanks for ur reply.
This works.
Reply all
Reply to author
Forward
0 new messages