Package-level declarations

Network Monitor

This utility is designed to monitor the status of the network.

Network monitoring

To monitor the state of the network, simply subscribe to the state flow.

val scope: CoroutineScope
val networkManager: NetwrokManager

scope.launch {
networkManager.networkMonitor.networkState.collect { state ->
// do something...
}
}

The type NetworkState provides the following information.

data class NetworkState(

/** If true - connected to internet */
val connected: Boolean,

/** If true - connected using Wi-Fi */
val wifi: Boolean,

/** If true - connected using mobile network but in roaming */
val roaming: Boolean
)

Types

Link copied to clipboard
interface NetworkMonitor

This utility is used to monitor the status of the network.

Link copied to clipboard
data class NetworkState(val connected: Boolean, val wifi: Boolean, val roaming: Boolean)

Represents network state.