[英]Create a new WiFi connection with proxy
I'm using the WifiManager with WifiConfiguration to create a WiFi connection on an Android device. 我正在将WifiManager与WifiConfiguration一起使用,以在Android设备上创建WiFi连接。 This all works successfully and I can happily create a WiFi connection in the OS.
这一切都成功完成,我可以在操作系统中愉快地创建WiFi连接。
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.
我在WifiConfiguration或WifiManager中看不到任何用于设置代理详细信息的机制。
Does anyone know how to set proxy details when creating a WiFi connection. 有谁知道在创建WiFi连接时如何设置代理详细信息。
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. 更新:此问题特定于Xamarin,stackoverflow中还有其他主题,这些主题详细介绍了本机Android中的解决方案,但是在这里,我正在寻找Xamarin解决方案。
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:
要创建代理设置,请在创建Wifi连接后执行以下操作:
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.