Package ej.net
Class HttpPollerConnectivityManager
- java.lang.Object
-
- android.net.ConnectivityManager
-
- ej.net.PollerConnectivityManager
-
- ej.net.HttpPollerConnectivityManager
-
public class HttpPollerConnectivityManager extends PollerConnectivityManager
Basic full java implementation. Consider the network is connected when there is at least oneNetworkInterfacewhich address is not0.0.0.0. It uses an HTTP request to check if it is connected to internet.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class android.net.ConnectivityManager
ConnectivityManager.NetworkCallback
-
-
Field Summary
Fields Modifier and Type Field Description static StringPROPERTY_HOSTProperty used to define the host.static StringPROPERTY_PAYLOADProperty used to define the payload.static StringPROPERTY_PORTProperty used to define the port.-
Fields inherited from class ej.net.PollerConnectivityManager
BASE_PROPERTY, INTERNET_CONNECTED, INTERNET_UNCONNECTED
-
-
Constructor Summary
Constructors Constructor Description HttpPollerConnectivityManager()Instantiates anHttpPollerConnectivityManagerwith System properties values.HttpPollerConnectivityManager(Timer timer)Instantiates anHttpPollerConnectivityManagerwith System properties values.HttpPollerConnectivityManager(Timer timer, long delay, long periodWhenAvaialble, long periodWhenLost, long periodWhenInternet)Instantiates anHttpPollerConnectivityManagerwith arguments values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NetworkCapabilitiesgetCapabilities(InetAddress connectedAddress)Gets the capabilities of a network.voidsetHttpValues(String host, String payload, int port)Sets the http values.-
Methods inherited from class ej.net.PollerConnectivityManager
cancel, getNetworkInterface, getNetworkInterfaces, log, log, startPolling, stopPolling
-
Methods inherited from class android.net.ConnectivityManager
doNotifyAvailabilityChange, doNotifyCapabilitiesChange, getActiveNetwork, getActiveNetworkInfo, getAllNetworks, getNetworkCapabilities, getNetworkInfo, notifyNetworkCallbacks, notifyNetworkCallbacks, registerDefaultNetworkCallback, registerNetworkCallback, setActiveNetwork, setAvailable, unregisterNetworkCallback
-
-
-
-
Field Detail
-
PROPERTY_PORT
public static final String PROPERTY_PORT
Property used to define the port.- See Also:
- Constant Field Values
-
PROPERTY_HOST
public static final String PROPERTY_HOST
Property used to define the host.- See Also:
- Constant Field Values
-
PROPERTY_PAYLOAD
public static final String PROPERTY_PAYLOAD
Property used to define the payload.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpPollerConnectivityManager
public HttpPollerConnectivityManager()
Instantiates anHttpPollerConnectivityManagerwith System properties values. It uses the system properties:- connectivity.http.host
- connectivity.http.port (optional default value is 80)
- connectivity.http.payload (optional default value will do a get at the root of the host)
- See Also:
PollerConnectivityManager()
-
HttpPollerConnectivityManager
public HttpPollerConnectivityManager(Timer timer)
Instantiates anHttpPollerConnectivityManagerwith System properties values. It uses the system properties:- connectivity.http.host
- connectivity.http.port (optional default value is 80)
- connectivity.http.payload (optional default value will do a get at the root of the host)
- Parameters:
timer- the timer to use, cannot benull.- See Also:
PollerConnectivityManager()
-
HttpPollerConnectivityManager
public HttpPollerConnectivityManager(Timer timer, long delay, long periodWhenAvaialble, long periodWhenLost, long periodWhenInternet)
Instantiates anHttpPollerConnectivityManagerwith arguments values.- Parameters:
timer- the timer to use, cannot benull.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 there is internet access.
-
-
Method Detail
-
setHttpValues
public void setHttpValues(@Nullable String host, @Nullable String payload, int port)
Sets the http values.- Parameters:
host- the host to use, cannot benull.payload- the payload to send, ifnulla simple get request at the root will be used.port- the port to use.
-
getCapabilities
protected NetworkCapabilities getCapabilities(InetAddress connectedAddress)
Description copied from class:PollerConnectivityManagerGets the capabilities of a network.- Overrides:
getCapabilitiesin classPollerConnectivityManager- Parameters:
connectedAddress- the address to get the capabilities from, cannot benull.- Returns:
- the capabilities of the address.
-
-