locked
Xamarin on Android - how to disconnect from Wifi and drop info about wifi network? RRS feed

  • Question

  • User371227 posted

    Hi,

    I need to disconnect from the wifi I am currently connected and prevent further attempts to connect to this network. How can I do it in Xamarin (may be with Plugin.Connectivity) ?

    Friday, August 24, 2018 5:26 PM

All replies

  • User74754 posted

    Register a BroadcastReceiver to ConnectivityManager.ConnectivityAction

    Get NetworkInfo from Intent: intent.GetParcelableExtra(ConnectivityManager.ExtraNetworkInfo) is NetworkInfo networkInfo

    Check if IsConnected and the ExtraInfo is the SSID (with quotes)

    case true: Find in WifiManager.ConfiguredNetworks the WifiConfiguration with the same SSID (with quotes) and call

    wifiManager.DisableNetwork(wifiConfiguration.NetworkId)

    Friday, August 24, 2018 9:08 PM