public class ConnectivityStatusRequester
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
STATE_CONNECTED
The interface has connected and is available to use.
|
static int |
STATE_CONNECTING
The interface is in the process of negotiating a connection.
|
static int |
STATE_DISCONNECTED
The interface has become disconnected and is now no longer able to route traffic.
|
static int |
STATE_DISCONNECTING
The interface is in the process of disconnecting and will no longer route traffic.
|
static int |
STATE_NOT_AVAILABLE
The interface is unavailable at this time.
|
static int |
STATE_UNKNOWN
An unexpected state change has occurred on this interface.
|
static int |
TYPE_CELLULAR
A connection provided by cellular communications (of any type or speed).
|
static int |
TYPE_GENERIC
A connection type that cannot be identified.
|
static int |
TYPE_VPN
A Virtual Private Network tunnel to another network elsewhere.
|
static int |
TYPE_WIFI
A connection provided via WiFi.
|
static int |
TYPE_WIMAX
A WiMAX connection.
|
static int |
TYPE_WIRED
A wired connection (usually Ethernet or USB).
|
static int |
TYPE_WIRELESS_HIGH_LATENCY
A wireless connection that is expected to have high latency, such as satellite.
|
static int |
TYPE_WIRELESS_LOW_LATENCY
A low-latency wireless connection that is not based around WiFi or cellular connections, such as Bluetooth.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectivityWatcher(IConnectivityWatcher watcher)
Add a class to the list of
IConnectivityWatcher classes that should be notified when
a network interface changes its state. |
boolean |
getConnectivityStatus()
Get the current connectivity status across all interfaces on this device.
|
int[] |
getCurrentConnectivityTypes()
Gets a list of the current interfaces that are available to the handset and in the
state
STATE_CONNECTED . |
static ConnectivityStatusRequester |
getDefaultInstance()
Get the default implementation of this class.
|
boolean |
isCellularConnected()
Convenience method equivalent to isTypeConnected(TYPE_CELLULAR)
|
boolean |
isTypeConnected(int type)
Test to see if an interface of a specific type is currently connected.
|
boolean |
isWiFiConnected()
Convenience method equivalent to
isTypeConnected(TYPE_WIFI) |
void |
removeConnectivityWatcher(IConnectivityWatcher watcher)
Stop notifying this class of network state changes.
|
static ConnectivityStatusRequester |
useCustomImplementation(ConnectivityStatusRequester instance)
Deprecated.
|
public static final int TYPE_GENERIC
public static final int TYPE_WIFI
public static final int TYPE_CELLULAR
public static final int TYPE_WIRED
public static final int TYPE_WIRELESS_HIGH_LATENCY
public static final int TYPE_WIRELESS_LOW_LATENCY
public static final int TYPE_VPN
public static final int TYPE_WIMAX
public static final int STATE_UNKNOWN
public static final int STATE_CONNECTING
public static final int STATE_CONNECTED
public static final int STATE_DISCONNECTING
public static final int STATE_DISCONNECTED
public static final int STATE_NOT_AVAILABLE
public static ConnectivityStatusRequester getDefaultInstance()
public static ConnectivityStatusRequester useCustomImplementation(ConnectivityStatusRequester instance)
public boolean getConnectivityStatus()
true
if there is any network interface in
STATE_CONNECTED
.public int[] getCurrentConnectivityTypes()
STATE_CONNECTED
.public void addConnectivityWatcher(IConnectivityWatcher watcher)
IConnectivityWatcher
classes that should be notified when
a network interface changes its state.public void removeConnectivityWatcher(IConnectivityWatcher watcher)
public boolean isWiFiConnected()
isTypeConnected(TYPE_WIFI)
true
if a WiFi connection is available.public boolean isCellularConnected()
true
if a cellular connection is available.public boolean isTypeConnected(int type) throws java.lang.IllegalArgumentException
type
- the network interface type to check for.true
if a network interface of this type is available and online.java.lang.IllegalArgumentException