Retrieve The Status Of The Wireless Access Point Or The Active Wi-Fi Profile; Open A Wi-Fi Socket Connection; Open A Wi-Fi Http Connection - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Development Guide
2.
Create an IF statement that tests the value of WLANInfo.WLAN_STATE_CONNECTED and the value returned by
WLANInfo.getWLANState(). The WLANInfo.getWLANState() method checks if a BlackBerry® device
has an IP address and can transfer data over a Wi-Fi® network. If the transceiver for the WLAN wireless access family is off,
this method returns WLANInfo.WLAN_STATE_DISCONNECTED.
if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {...}

Retrieve the status of the wireless access point or the active Wi-Fi profile

You can let a BlackBerry® device application retrieve status information such as the data rate of the connection, the wireless
LAN standards used (802.11a™, 802.11b™, or 802.11g™), the SSID of the associated access point, or the name of the Wi-Fi profile
in use. The transceiver for the WLAN wireless access family must be connected to a wireless access point.
1.
Import the net.rim.device.api.system.WLANInfo class.
2.
Invoke WLANInfo.getAPInfo(), storing a reference to WLANInfo.WLANAPInfo that this method returns.
The WLANInfo.WLANAPInfo object contains a snapshot of the current wireless network.
WLANInfo.WLANAPInfo info = WLANInfo.getAPInfo();
If the BlackBerry device is not connected to an access point, the WLANInfo.getAPInfo() method returns null.

Open a Wi-Fi socket connection

The interface=wifi parameter applies only to TCP/UDP connections. To establish a Wi-Fi® connection and use a Wi-Fi
API in a BlackBerry® device application, the wireless service provider must support Wi-Fi access.
1.
Import the following classes:
• java.lang.String
• javax.microedition.io.Connector
2.
Import the javax.microedition.io.StreamConnection interface.
3.
Invoke Connector.open(), specify socket as the protocol, and append the deviceside=true parameter and
the interface=wifi parameter to the end of the URL string value.
private static String URL = "socket://local_machine_IP:
4444;deviceside=true;interface=wifi";
StreamConnection conn = null;
conn = (StreamConnection)Connector.open(URL);

Open a Wi-Fi HTTP connection

The interface=wifi parameter applies only to TCP/UDP connections. To establish a Wi-Fi® connection and use a Wi-Fi
API in a BlackBerry® device application, the wireless service provider must support Wi-Fi access.
1.
Import the following classes:
64
Wi-Fi connections

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment

Table of Contents