Using Network Access and ConnectivityManager, help needed

axaaxa Member ✭✭
edited March 13 in Xamarin.Android

Might anyone be able to show me if there are xamarin/c# examples of using Network Access and the ConnectivityManager as in these examples:

https://developer.android.com/training/wearables/data-layer/network-access.html

https://github.com/googlesamples/android-WearHighBandwidthNetworking/blob/master/Wearable/src/main/java/com/example/android/wearable/wear/wearhighbandwidthnetworking/MainActivity.java

Im trying to figure out how to gain access to the internet resource when a WearOS device has Bluetooth on and active, and thus setting the wifi connection disconnected/off

networkCallback = object : ConnectivityManager.NetworkCallback() {
    override fun onAvailable(network: Network) {
        if (bindProcessToNetwork(network)) {
            // socket connections will now use this network
        } else {
            // app doesn't have android.permission.INTERNET permission
        }
    }
}

In particular I do not understand how ConnectivityManager.NetworkCallback() could be assigned.
In Xamarin ConnectivityManager.NetworkCallback() is a class.
In Xamarin onAvailable is a method that takes a parameter, i would expect one or both of these to be events or at least some type of delegate.

Help here would be MASSIVELY appreciated.

Sign In or Register to comment.