title: Connect to wifi programmatically in Xamarin Forms Android 10
body: <p>I am unable to connect to wifi in Android 10. The code I have works fine till Android 9, I have been trying to implement the same for Android 10 without any luck :(</p>
  
  <pre><code>        private void RequestNetwork(string _ssid, string _passphrase)
          {
              var specifier = new WifiNetworkSpecifier.Builder()
                  .SetSsid(_ssid)
                  .SetWpa2Passphrase(_passphrase)
                  .Build();
  
              var request = new NetworkRequest.Builder()
                  .AddTransportType(TransportType.Wifi) // we want WiFi
                  .RemoveCapability(NetCapability.Internet) // Internet not required
                  .SetNetworkSpecifier(specifier) // we want _our_ network
                  .Build();
  
              NetworkCallback _callback = new NetworkCallback();
              connection_manager.RequestNetwork(request, _callback);
          }
  
          private class NetworkCallback : ConnectivityManager.NetworkCallback
          {
              public Action NetworkAvailable { get; set; }
              //bool IsBusy = false;
              public override void OnAvailable(Network network)
              {
                  base.OnAvailable(network);
                  connection_manager.BindProcessToNetwork(network);
              }
  
              public override void OnUnavailable()
              {
                  base.OnUnavailable();
              }
          }
  </code></pre>