NetworkConnectionInterceptor

class NetworkConnectionInterceptor(val context: Context) : Interceptor

An OkHttp interceptor that checks for network connectivity before making a network request.

Parameters

context

The application context used to access the connectivity service.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun intercept(chain: Interceptor.Chain): Response

Intercepts the network request and checks if there is an active network connection. Throws an IOException if there is no active connection.

Link copied to clipboard
fun isConnected(context: Context): Boolean

Checks if the device is currently connected to a network.