--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/UhTcFdJg7dwJ.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
To change Wi-Fi proxy settings on ICS, you need access to private APIs.
The following code works on my CM9 device.
WifiManager manager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
if (!manager.isWifiEnabled()) return;
List<WifiConfiguration> configurationList = manager.getConfiguredNetworks();
WifiConfiguration configuration = null;
int cur = manager.getConnectionInfo().getNetworkId();
for (int i = 0; i < configurationList.size(); ++i)
{
WifiConfiguration wifiConfiguration = configurationList.get(i);
if (wifiConfiguration.networkId == cur)
configuration = wifiConfiguration;
}
if (configuration == null) return;
WifiConfiguration config = new WifiConfiguration(configuration);
config.ipAssignment = WifiConfiguration.IpAssignment.UNASSIGNED;
config.proxySettings = WifiConfiguration.ProxySettings.STATIC;
config.linkProperties.setHttpProxy(new ProxyProperties("127.0.0.1", 3128, ""));
manager.updateNetwork(config);
manager.saveConfiguration();
在 2012年5月4日星期五UTC+8下午8时05分09秒,Francesco Pace写道:
Hi I am trying to add the above code to programatically set the proxy setting for a particular wifi config, but I am running into problem where in Eclipse shows errors for the code >> WifiConfiguration.IpAssignment.UNASSIGNED <<
any ideas on how to get this working?
please check attached screenshot.
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/vr3Ut1b1MHgJ.