Hello,
i need to create app which needs to use wi-fi network which has no internet. I found possibility to do it using connectivitymanager and network callback, but I found code only in Java and I have really problem to implement in C# NetworkCallback with OnAvailable method inside.
connectivityManager.requestNetwork(builder.build(), new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.RELEASE.equalsIgnoreCase("6.0")) {
if (!Settings.System.canWrite(mActivity)) {
Intent goToSettings = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
goToSettings.setData(Uri.parse("package:" + mActivity.getPackageName()));
mActivity.startActivity(goToSettings);
}
}
connectivityManager.bindProcessToNetwork(null);
if (mSsid.contains("my_iot_device-xxxxxxxxx")) {
connectivityManager.bindProcessToNetwork(network);
}
}
I know, it should be managed somehow using delegates and events in C#, but I am not really sure how. Do you have any ideas how to implements this NetworkCallback with method inside? Is there any other possibility how to accomplish this task?