Connection

The Connection object gives access to the device's cellular and wifi connection information.

Since: BlackBerry WebWorks 2.0

Installation:

To use this API in your project, add the connection plugin:

webworks plugin add com.blackberry.connection
Events:
void connectionchange
Properties:
String type
Constants:
String BB
String BLUETOOTH_DUN
String CELL_2G
String CELL_3G
String CELL_4G
String ETHERNET
String NONE
String UNKNOWN
String USB
String VPN
String WIFI

connectionchange

This event is fired by the system. If you want to listen to the event you can do so using the document.addEventListener function and remove the listener using the document.removeEventListener function. The connectionchange event is triggered whenever the network connection type changes.

Synopsis:

Event

Parameters:

yourCallbackFunction {Function}

The callback function that will be invoked on the connectionchange event.

yourCallbackFunction.info {Object}

An object with the pertinent information.

yourCallbackFunction.info.oldType {Number}

The network connection type prior to the event.

yourCallbackFunction.info.newType {Number}

The new network connection type.

Example:

<script type="text/javascript">

    function onChange(info) {
        alert("The network connection type used to be: " + info.oldType + " and is now: " + info.newType);
    }

    document.addEventListener("connectionchange", onChange);

</script>
            

type

The type of network connection that is being used by the application. Note that CELL_4G is always returned for cellular connection.

Synopsis:

read-only
String blackberry.connection.type

BB

BlackBerry Bridge connection

Synopsis:

constant
String blackberry.connection.BB = "rim-bb"

BLUETOOTH_DUN

Bluetooth tethering connection

Synopsis:

constant
String blackberry.connection.BLUETOOTH_DUN = "bluetooth_dun"

CELL_2G

Cellular 2G connection

Synopsis:

constant
String blackberry.connection.CELL_2G = "2g"

CELL_3G

Cellular 3G connection

Synopsis:

constant
String blackberry.connection.CELL_3G = "3g"

CELL_4G

Cellular 4G connection

Synopsis:

constant
String blackberry.connection.CELL_4G = "4g"

ETHERNET

Wired ethernet connection

Synopsis:

constant
String blackberry.connection.ETHERNET = "ethernet"

NONE

No connection

Synopsis:

constant
String blackberry.connection.NONE = "none"

UNKNOWN

Unknown connection

Synopsis:

constant
String blackberry.connection.UNKNOWN = "unknown"

USB

USB connection

Synopsis:

constant
String blackberry.connection.USB = "usb"

VPN

VPN connection

Synopsis:

constant
String blackberry.connection.VPN = "vpn"

WIFI

Wi-Fi connection

Synopsis:

constant
String blackberry.connection.WIFI = "wifi"

Last modified: 2014-10-09



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus