Class NetworkStateProvider
-
- All Implemented Interfaces:
public final class NetworkStateProviderHandler which monitors connectivity and provides network state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceNetworkStateProvider.NetworkStateListenerListener which is used to listen and react to network state changes.
-
Constructor Summary
Constructors Constructor Description NetworkStateProvider(ConnectivityManager connectivityManager)
-
Method Summary
Modifier and Type Method Description final BooleanisConnected()Checks if the current device is connected to the Internet, based on the API level. final Unitsubscribe(NetworkStateProvider.NetworkStateListener listener)Subscribes to network state changes through a listener. final Unitunsubscribe(NetworkStateProvider.NetworkStateListener listener)Removes a listener for network state changes. -
-
Constructor Detail
-
NetworkStateProvider
NetworkStateProvider(ConnectivityManager connectivityManager)
-
-
Method Detail
-
isConnected
final Boolean isConnected()
Checks if the current device is connected to the Internet, based on the API level.
- Returns:
If the device is connected or not.
-
subscribe
final Unit subscribe(NetworkStateProvider.NetworkStateListener listener)
Subscribes to network state changes through a listener.
- Parameters:
listener- Handler which receives connection change events.
-
unsubscribe
final Unit unsubscribe(NetworkStateProvider.NetworkStateListener listener)
Removes a listener for network state changes.
- Parameters:
listener- Handler to be removed.
-
-
-
-