Package com.castlabs.android.network

# Class DefaultConnectivityCheck

java.lang.Object
com.castlabs.android.network.DefaultConnectivityCheck

All Implemented Interfaces:
  `ConnectivityCheck`

public class DefaultConnectivityCheck extends Object implements ConnectivityCheck
The default implementation of the connectivity checker. This implementation uses the systems `ConnectivityManager` to resolve the current `NetworkInfo` and then uses `NetworkInfo.isConnected()` to check for connectivity.

If you specify a lookup host name, a name lookup will be done to verify connectivity if the `ConnectivityManager` reports that the device is connected. We do this because there seems to be a slight delay and inaccuracy where the `ConnectivityManager` reports that we have connectivity, but that is actually not the case. To verify connectivity, we do a host name lookup for the given host to verify connectivity. This is an optional step and will be omitted if no lookup host name is specified.

Since:
  3.1.2

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultConnectivityCheck(Context context)`
  Create a new instance of the connectivity checker to "google.com" lookup host
  `DefaultConnectivityCheck(Context context, String lookupHost)`
  Create a new instance of the connectivity checker.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isConnected()`
  Returns true if an internet connection is available

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DefaultConnectivityCheck

    public DefaultConnectivityCheck(@NonNull Context context)
    Create a new instance of the connectivity checker to "google.com" lookup host
    Parameters:
      `context` - The context

  - ### DefaultConnectivityCheck

    public DefaultConnectivityCheck(@NonNull Context context, @Nullable String lookupHost)
    Create a new instance of the connectivity checker.
    Parameters:
      `context` - The context
      `lookupHost` - The lookup host. If this is specified, the connectivity check will try to resolve the IP address of the given host name to verify connectivity.

- ## Method Details

  - ### isConnected

    public boolean isConnected()
    Description copied from interface: `ConnectivityCheck`
    Returns true if an internet connection is available
    Specified by:
      `isConnected` in interface `ConnectivityCheck`
    Returns:
      True if an internet connection is available