<BlockSwitcher>
<Block name="Java">

```java
Amplify.Hub.subscribe(
    HubChannel.DATASTORE,
    hubEvent -> DataStoreChannelEventName.NETWORK_STATUS.toString().equals(hubEvent.getName()),
    hubEvent -> {
        NetworkStatusEvent event = (NetworkStatusEvent) hubEvent.getData();
        Log.i("MyAmplifyApp", "User has a network connection: " + event.getActive());
    }
);
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
Amplify.Hub.subscribe(HubChannel.DATASTORE,
    { it.name.equals(DataStoreChannelEventName.NETWORK_STATUS.toString()) },
    { 
        val networkStatus = it.data as NetworkStatusEvent
        Log.i("MyAmplifyApp", "User has a network connection? ${networkStatus.active}")
    }
)
```

</Block>
<Block name="Kotlin - Coroutines">

```kotlin
Amplify.Hub.subscribe(DATASTORE)
    { it.name == NETWORK_STATUS.toString() }
    .collect {
        val event = it.data as NetworkStatusEvent
        Log.i("MyAmplifyApp", "User has a network connection: ${event.active}")
    }
```

</Block>
<Block name="RxJava">

```java
RxAmplify.Hub.on(HubChannel.DATASTORE)
    .filter(hubEvent -> DataStoreChannelEventName.NETWORK_STATUS.toString().equals(hubEvent.getName()))
    .subscribe(hubEvent -> {
        NetworkStatusEvent event = (NetworkStatusEvent) hubEvent.getData();
        Log.i("MyAmplifyApp", "User has a network connection: " + event.getActive());
    });
```

</Block>

</BlockSwitcher>
