How users/developers can set the Android's proxy configuration for versions 2.x?

lechuckcaptain picture lechuckcaptain · Feb 25, 2012 · Viewed 8.8k times · Source

I would like to know if it's possible for the user, or for the developers to set the Wi-Fi Access Point proxy settings in Android versions 2.x (I know that it's possible for 3.x or greater versions editing the AP configuration into the Wireless settings), in order to get the settings from code in the following way:

ProxySelector defaultProxySelector = ProxySelector.getDefault();
List<Proxy> proxyList = defaultProxySelector.select("http://www.google.it");

(that should be the right way to get the current proxy configuration of the Android device)

I know there is a hidden Activity into the Android source code, called ProxySelector (please be careful, it has the same name of the java.net.ProxySelector, but it's an Android Activity and it's located on the package: com.android.settings.ProxySelector) but it sets something like a global proxy configuration that seems to be ignored by the default ProxySelector class.

This question is because it seems that for Android 3.x or greater versions the standard way to use the java.net.ProxySelector seems to work without problems, but not for Android 2.x versions. It's a changed behaviour or am I doing something wrong?

Should we use the global proxy settings for Android 2.x versions in alternative? By the way we can read the global proxy settings in the following way:

Settings.Secure.getString(getApplicationContext().getContentResolver(),Settings.Secure.HTTP_PROXY);

Answer

Sparky picture Sparky · Mar 14, 2012

I don't think there was any platform-level support for Wi-Fi proxies before Gingerbread or prerhaps Honeycomb.

Edit:
An Android engineer who works on this part of the platform confirms that the system didn't have proxies for different network types (e.g., Wi-Fi) until Honeycomb. So there is no "official" way to get the Wi-Fi proxy for 2.x.