Object NetworkUtils

  • All Implemented Interfaces:

    
    public class NetworkUtils
    
                        

    Utility class for checking network connectivity status.

    This utility provides a unified way to check network availability across different Android API levels. It handles both modern (API 23+) and legacy network checking approaches to ensure compatibility with a wide range of devices.

    Since:

    4.3.2

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean isNetworkAvailable(Context context) Checks if a network connection is currently available and validated.
      final Unit clearCache() Force clear the network state cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • isNetworkAvailable

         final Boolean isNetworkAvailable(Context context)

        Checks if a network connection is currently available and validated.

        This method performs a comprehensive network availability check that:

        • On API 23+: Verifies both internet capability and network validation

        • On older APIs: Falls back to checking connected state of active network

        The validation check ensures that the network can actually reach the internet, not just that it's connected to a router or access point.

        Parameters:
        context - The application context used to access system services
        Returns:

        true if a validated network connection is available, false otherwise

      • clearCache

         final Unit clearCache()

        Force clear the network state cache. Useful when you need an immediate accurate network check.