getCurrentState

abstract fun getCurrentState(): Flow<NetworkState>(source)

Returns a cold Flow that samples the active network's INTERNET capability before registering a default-network callback. Sampling and registration are not an atomic snapshot.

The sample emits NetworkState.CONNECTED or NetworkState.UNAVAILABLE. Subsequent callbacks emit CONNECTED, NetworkState.LOST, or UNAVAILABLE; LOSING and capability changes are logged without emitting. Consecutive equal values are suppressed.

Each collector registers its own callback, removed when collection closes. Callback registration errors can terminate collection.

Return

Connectivity observations, not a check that a particular request will succeed.