qnx.net.NetworkManager

NetworkManager

Properties | Methods


Packageqnx.net
Classpublic class NetworkManager
InheritanceNetworkManager Inheritance flash.events.EventDispatcher

The NetworkManager class allows you to monitor the following network connection types:

  • Wi-Fi
  • Bluetooth
  • VPN
  • cellular

It provides functions that you can call to check if the device is connected, and to check what type of connection has been made.

In addition, you can listen for CHANGE events to respond to when the connection status changes:

     NetworkManager.networkManager.addEventListener(Event.CHANGE, onNetInfoChange);
     

The following listing returns a NetworkManager instance, then returns information about the current Wi-Fi network and stores it in a String:

    stats = NetworkManager.networkManager.getNetworkStats(NetworkType.WIFI);
    txt += "WIFI Network is " + (NetworkManager.networkManager.isConnected(NetworkType.WIFI) ? "Connected" : "Disconnected") + "\n";
    if (stats) {
        txt += "Name: " + stats.name + "\n";
        txt += "inBytes: " + stats.inBytes + "\n";
        txt += "outBytes: " + stats.outBytes + "\n";
        txt += "inPackets: " + stats.inPackets + "\n";
        txt += "outPackets: " + stats.outPackets + "\n";
        txt += "- toString output: " + NetworkManager.networkManager.getNetworkStats(NetworkType.WIFI).toString() + "\n";
    }
     


Class information:
PlayBook Tablet OS Version: 2.0
Found in:  QNXNetwork.ane

See also

NetworkType



Public Properties

 PropertyDefined By
  networkManager : NetworkManager
[static] [read-only] Returns the NetworkManager singleton instance.
NetworkManager

Public Methods

 MethodDefined By
  
Do not instantiate this class.
NetworkManager
  
Gets the current default network type being used for internet traffic.
NetworkManager
  
getNetworkInterface(type:String = null):NetworkInterface
Gets the NetworkInterface class for the specified network type.
NetworkManager
  
Returns the stats for the specified network type.
NetworkManager
  
Return the type of network traffic is being forced to be routed over.
NetworkManager
  
isConnected(type:String = null):Boolean
Returns true if the device is connected to a network, otherwise false.
NetworkManager
  
isSupported(type:String):Boolean
Returns true if the specified network type is supported, otherwise false.
NetworkManager
  
setRoutingInterface(type:String):Boolean
Force traffic from new connections to be routed over the indicated network type.
NetworkManager

Property Detail

networkManager


networkManager:NetworkManager  [read-only]

Returns the NetworkManager singleton instance.


Implementation

public static function get networkManager():NetworkManager

Constructor Detail

NetworkManager()


public function NetworkManager()

Do not instantiate this class.

Instead use NetworkManager.networkManager to return the singleton instance.

See also

NetworkManager.networkManager

Method Detail

getDefaultNetworkType()


public function getDefaultNetworkType():String

Gets the current default network type being used for internet traffic.

Returns

String — String constant from NetworkType

See also

NetworkType

getNetworkInterface()


public function getNetworkInterface(type:String = null):NetworkInterface

Gets the NetworkInterface class for the specified network type.

Parameters

type:String (default = null) — The type of network. If the type is null, it will return the interface for the default network.

Returns

NetworkInterface — The NetworkInterface class of the specified network.

getNetworkStats()


public function getNetworkStats(type:String):NetworkStats

Returns the stats for the specified network type.

Type must be one of the following:

  • NetworkType.WIFI
  • NetworkType.VPN
  • NetworkType.CELLULAR
  • NetworkType.BLUETOOTH

Parameters

type:String — The type of network to return stats for.

Returns

NetworkStats — NetworkStats The network stats for the specified network type.

See also

NetworkStats
NetworkType

getRoutingInterface()


public function getRoutingInterface():String

Return the type of network traffic is being forced to be routed over.

Returns

String — The type of network traffic is being routed over or null if route is based on address.

isConnected()


public function isConnected(type:String = null):Boolean

Returns true if the device is connected to a network, otherwise false.

Type must be one of the following:

  • NetworkType.WIFI
  • NetworkType.VPN
  • NetworkType.CELLULAR
  • NetworkType.BLUETOOTH

Parameters

type:String (default = null) — The type of network to check for connectivity. If null is passed it will check the default network type.

Returns

Boolean — Boolean for connected or not.

See also

NetworkType

isSupported()


public function isSupported(type:String):Boolean

Returns true if the specified network type is supported, otherwise false.

The following types are supported:

  • NetworkType.WIFI
  • NetworkType.VPN
  • NetworkType.CELLULAR
  • NetworkType.BLUETOOTH

Parameters

type:String — The network type.

Returns

Boolean — Returns true if the network type is supported on the device.

See also

NetworkType

setRoutingInterface()


public function setRoutingInterface(type:String):Boolean

Force traffic from new connections to be routed over the indicated network type.

Parameters

type:String — The type of network to route traffic over. If null, the default will be restored allowing any interface to be used. If there is no interface of the indicated type, the parameter will be interpreted as the interface name to use.

Returns

Boolean — true if successful, false if there is no matching interface.