0

I'm using the WifiManager with WifiConfiguration to create a WiFi connection on an Android device. This all works successfully and I can happily create a WiFi connection in the OS.

I would now like to allow the user to provide proxy details, host, port, username and password. I cannot see any mechanism in the WifiConfiguration or WifiManager to set the proxy details.

Does anyone know how to set proxy details when creating a WiFi connection.

UPDATE: This issue is specific to Xamarin, there are other topics in stackoverflow that detail solutions in native Android, but here I am looking for a Xamarin solution.

Slicc
  • 3,217
  • 7
  • 35
  • 70
  • Possible duplicate of [How can I set ProxySettings and ProxyProperties on Android Wi-Fi connection using Java?](http://stackoverflow.com/questions/12486441/how-can-i-set-proxysettings-and-proxyproperties-on-android-wi-fi-connection-usin) – SushiHangover Mar 21 '17 at 15:19

1 Answers1

0

Well, rightly or wrongly this is how I am doing it (and it seems to work so far). To create a proxy setting, after I have created the Wifi connection I do:

            Lang.JavaSystem.SetProperty("http.proxySet", "true");
            Java.Lang.JavaSystem.SetProperty("http.proxyHost", _proxyName);
            Java.Lang.JavaSystem.SetProperty("http.proxyPort", _proxyPort);
            Java.Lang.JavaSystem.SetProperty("http.proxyUser", _proxyUsername);
            Java.Lang.JavaSystem.SetProperty("http.proxyPassword", _proxyPassword);

And when I want to clear the proxy settings I do:

            Java.Lang.JavaSystem.ClearProperty("http.proxySet");
            Java.Lang.JavaSystem.ClearProperty("http.proxyHost");
            Java.Lang.JavaSystem.ClearProperty("http.proxyPort");
            Java.Lang.JavaSystem.ClearProperty("http.proxyUser");
            Java.Lang.JavaSystem.ClearProperty("http.proxyPassword");
Slicc
  • 3,217
  • 7
  • 35
  • 70