Package 

Class ConnectivityMonitor


  • 
    public class ConnectivityMonitor
    
                        

    Connectivity monitor can be used to monitor changes to host network connectivity changes.

    • Method Detail

      • addListener

         ConnectivityMonitor addListener(@NonNull() ConnectivityMonitor.Listener listener)

        Adds the specified listener to the list of listeners that will be notified when thehost device's network connectivity state changes. Please call removeListener to free up resources.

        Please note that the design of the connectivity monitor intentionally discouragesthe practice of using anonymous objects as listeners to avoid resource leaks. The listenerwill be held weakly by this class. Anonymous listeners may get collected by GC immediately.

        Parameters:
        listener - reference to the listener.
      • isConnected

         boolean isConnected()

        Checks if the host device has an active network connection.

      • isConnected

         boolean isConnected(Array<int> allowedTypes)

        Checks if the host device is connected to the using one of the allowed network type.

        Parameters:
        allowedTypes - array of allowed network types.
      • isWifiConnection

         boolean isWifiConnection()

        Checks if the active network connection is a Wi-Fi network.