|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
totalcross.lang.Objecttotalcross.net.ConnectionManager
public class ConnectionManager
The ConnectionManager allows you to open and close remote connections from your application.
Although its behavior may differ from one platform to another, the objective is to provide a unified process to
handle connections across all supported platforms.
Currently, this class supports only GPRS connections running on Windows Mobile and BlackBerry.
The configuration string received by setDefaultConfiguration is a list of parameters in the format "parameter=value"
separated by a semi-colon ";" (spaces are not allowed).
To configure a GPRS connection, you may provide the following parameters:
|
Parameter |
Description |
apn |
The APN over which the connection will be made. |
username |
The user name to use to connect to the APN. May be omitted if not required by the specified APN. |
password |
The password to use to connect to the APN. May be omitted if not required by the specified APN. |
| Field Summary | |
|---|---|
static int |
CELLULAR
This flag indicates a cellular connection. |
static int |
CRADLE
This flag indicates a cradle (USB to PC) connection. |
static int |
GPRS
Deprecated. As of TotalCross 1.20, replaced by CELLULAR. |
static int |
WIFI
This flag indicates a Wi-Fi connection. |
| Method Summary | |
|---|---|
static void |
close()
Attempts to close all open remote connections. |
static String |
getHostAddress(String hostName)
Returns the IP address of the given host in textual representation, or null if this information is not available. |
static String |
getHostName(String hostAddress)
Returns the name of the given host, or null if this information is not available. |
static String |
getLocalHost()
Returns a textual representation of the IP address currently assigned to this device. |
static boolean |
isAvailable(int type)
Checks if an specific connection is currently available. |
static void |
open()
Attempts to establish a remote connection in the first available connection in the following priority list: CRADLE, WIFI and CELLULAR. |
static void |
open(int type)
Attempts to establish a remote connection using the given connection. |
static void |
setDefaultConfiguration(int type,
String configuration)
Used to configure the connection to be used by the application. |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int CRADLE
public static final int WIFI
public static final int CELLULAR
public static final int GPRS
CELLULAR.| Method Detail |
|---|
public static void setDefaultConfiguration(int type,
String configuration)
throws IOException
CELLULAR connections.
type - one of the connection type constants defined by the ConnectionManager.configuration - list of parameters in the format "parameter=value" separated by a semi-colon ";".
IllegalArgumentIOException - if type is invalid.
IOException - if an I/O error occurs while configuring the connection.CRADLE,
WIFI,
CELLULAR
public static boolean isAvailable(int type)
throws IOException
type - one of the connection type constants defined by the ConnectionManager.
IllegalArgumentIOException - if type is invalid.
IOException - if an I/O error occurs while checking connection availability.CRADLE,
WIFI,
CELLULAR
public static void open()
throws IOException
CRADLE, WIFI and CELLULAR.
IOException - if an I/O error occurs while opening the connection.
public static void open(int type)
throws IOException
type - one of the connection type constants defined by the ConnectionManager.
IllegalArgumentIOException - if type is invalid.
IOException - if an I/O error occurs while opening the connection.CRADLE,
WIFI,
CELLULAR
public static void close()
throws IOException
IOException - if an I/O error occurs while closing a connection.
public static String getHostAddress(String hostName)
throws UnknownHostException
hostName - the host's name.
UnknownHostException - if the given host is unknown or cannot be reached.
public static String getHostName(String hostAddress)
throws UnknownHostException
hostAddress - textual representation of the host's IP address.
UnknownHostException - if the given host is unknown or cannot be reached.
public static String getLocalHost()
throws UnknownHostException
UnknownHostException - if the local host is unknown or cannot be reached.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||