public class PollerConnectivityManager extends ConnectivityManager
NetworkInterface
which address is not 0.0.0.0
.ConnectivityManager.NetworkCallback
Constructor and Description |
---|
PollerConnectivityManager()
Instantiates a
PollerConnectivityManager with default periods and delay and a new timer. |
PollerConnectivityManager(Timer timer)
Instantiates a
PollerConnectivityManager with default value. |
PollerConnectivityManager(Timer timer,
long delay,
long period)
Instantiates a
PollerConnectivityManager with the same period when up or not. |
PollerConnectivityManager(Timer timer,
long delay,
long periodWhenAvailable,
long periodWhenLost)
Instantiates a
PollerConnectivityManager with the different periods when available or not. |
PollerConnectivityManager(Timer timer,
long delay,
long periodWhenAvaialble,
long periodWhenLost,
long periodWhenInternet)
Instantiates a
PollerConnectivityManager with the same period when connected or not. |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the associated timer.
|
protected NetworkCapabilities |
getCapabilities(java.net.InetAddress connectedAddress)
Gets the capabilities of a network.
|
protected java.net.NetworkInterface |
getNetworkInterface(java.lang.String name)
Isolate for testing.
|
protected java.util.Enumeration<java.net.NetworkInterface> |
getNetworkInterfaces()
Isolate for testing.
|
protected void |
log(java.lang.String msg)
Logs a message.
|
protected void |
log(java.lang.String msg,
java.lang.Throwable t)
Logs a message and a throwable.
|
void |
startPolling(long delay)
Starts the polling function.
|
void |
stopPolling()
Stops the polling function.
|
doNotifyAvailabilityChange, doNotifyCapabilitiesChange, getActiveNetwork, getActiveNetworkInfo, getAllNetworks, getNetworkCapabilities, getNetworkInfo, notifyNetworkCallbacks, notifyNetworkCallbacks, notifyNetworkCallbacks, registerDefaultNetworkCallback, registerNetworkCallback, setActiveNetwork, setAvailable, unregisterNetworkCallback
public PollerConnectivityManager()
PollerConnectivityManager
with default periods and delay and a new timer.public PollerConnectivityManager(Timer timer)
PollerConnectivityManager
with default value.timer
- the timer to use.public PollerConnectivityManager(Timer timer, long delay, long period)
PollerConnectivityManager
with the same period when up or not.timer
- the timer to use.delay
- the delay before the start.period
- the period for the polling.public PollerConnectivityManager(Timer timer, long delay, long periodWhenAvailable, long periodWhenLost)
PollerConnectivityManager
with the different periods when available or not. The same period is used wth or without internet access when availble.timer
- the timer to use.delay
- the delay before the start.periodWhenAvailable
- the period for the polling when at least one interface is available.periodWhenLost
- the period for the polling when all the interface are down.public PollerConnectivityManager(Timer timer, long delay, long periodWhenAvaialble, long periodWhenLost, long periodWhenInternet)
PollerConnectivityManager
with the same period when connected or not.timer
- the timer to use.delay
- the delay before the start.periodWhenAvaialble
- the period for the polling when at least one interface is available.periodWhenLost
- the period for the polling when all the interface are down.periodWhenInternet
- the period for the polling when ther is internet access.public void startPolling(long delay)
delay
- the delay before starting.public void stopPolling()
public void cancel()
protected void log(java.lang.String msg)
msg
- the message to log.protected void log(java.lang.String msg, java.lang.Throwable t)
msg
- the message to log.t
- a throwable to print.protected NetworkCapabilities getCapabilities(java.net.InetAddress connectedAddress)
connectedAddress
- the address to get the capabilities from.protected java.util.Enumeration<java.net.NetworkInterface> getNetworkInterfaces() throws java.net.SocketException
java.net.SocketException
- if an I/O exception occurs.protected java.net.NetworkInterface getNetworkInterface(java.lang.String name) throws java.net.SocketException
name
- the name of the interface.java.net.SocketException
- if an I/O exception occurs.