NETWORK EVENT:
Using the NETWORK_CHANGE event, Add this listener in the applications - creationComplete property.
NativeApplication.nativeApplication.addEventListener(Event.NETWORK_CHANGE, onNetworkChangeHandler);
private function onNetworkChangeHandler(event:Event):void
{
Alert.show("Network Event Triggered");
}
Check the above scenario by disabling & enabling the Network connections manually in start->settings->Network Connections.
IS INTERNET LIVE OR NOT:
Using the URLMonitor class, The defined URL is monitored , If the network is failed , The event dispatches the status using the urlMonitor.available property.Refer the below code:
private var urlMonitor:URLMonitor;
private function checkNetworkLive():void
{
var url:URLRequest = new URLRequest("http://www.google.com/");
url.method = "HEAD";
urlMonitor = new URLMonitor(url);
urlMonitor.pollInterval = 3000;
urlMonitor.addEventListener(StatusEvent.STATUS,statusChanged);
urlMonitor.start();
}
public function statusChanged(event:StatusEvent):void
{
if(urlMonitor.available)
{
Alert.show("InterNet Live");
}
else
{
Alert.show("InterNet Failed");
}
}
Using the NETWORK_CHANGE event, Add this listener in the applications - creationComplete property.
NativeApplication.nativeApplication.addEventListener(Event.NETWORK_CHANGE, onNetworkChangeHandler);
private function onNetworkChangeHandler(event:Event):void
{
Alert.show("Network Event Triggered");
}
Check the above scenario by disabling & enabling the Network connections manually in start->settings->Network Connections.
IS INTERNET LIVE OR NOT:
Using the URLMonitor class, The defined URL is monitored , If the network is failed , The event dispatches the status using the urlMonitor.available property.Refer the below code:
private var urlMonitor:URLMonitor;
private function checkNetworkLive():void
{
var url:URLRequest = new URLRequest("http://www.google.com/");
url.method = "HEAD";
urlMonitor = new URLMonitor(url);
urlMonitor.pollInterval = 3000;
urlMonitor.addEventListener(StatusEvent.STATUS,statusChanged);
urlMonitor.start();
}
public function statusChanged(event:StatusEvent):void
{
if(urlMonitor.available)
{
Alert.show("InterNet Live");
}
else
{
Alert.show("InterNet Failed");
}
}
No comments:
Post a Comment