Overview
NetworkHelper is a utility class that provides methods to verify network availability on the device. It uses Android’s ConnectivityManager to check for active internet connections.
Package: com.bsvillarraga.spaceflightnews.core.network
Source: NetworkHelper.kt:11
Constructor
Android context used to access system services. Injected via Dagger/Hilt.
Methods
isNetworkAvailable
Checks if the device has an active internet connection.Boolean
trueif an active network connection with internet capability is availablefalseif no network connection is available or the connection lacks internet capability
Implementation Details
The method performs the following checks:- Gets the
ConnectivityManagersystem service - Retrieves the active network
- Gets the network capabilities for the active network
- Verifies the network has
NET_CAPABILITY_INTERNET
Dependencies
This class uses the following Android APIs:android.net.ConnectivityManagerandroid.net.NetworkCapabilities