用户/开发人员如何为 2.x 版设置 Android 的代理配置? [英] How users/developers can set the Android's proxy configuration for versions 2.x?

查看:18
本文介绍了用户/开发人员如何为 2.x 版设置 Android 的代理配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道用户或开发人员是否可以在 Android 2.x 版中设置 Wi-Fi 接入点代理设置(我知道 3.x 或更高版本可以编辑AP配置进入无线设置),以便通过以下方式从代码中获取设置:

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");

(这应该是获取当前代理配置的正确方法Android 设备)

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

我知道Android源代码中有一个隐藏的Activity,叫做ProxySelector(请注意,它与java.net.ProxySelector同名,但它是一个 Android Activity,它位于包中:com.android.settings.ProxySelector)但它设置了类似全局代理配置的东西,似乎被默认的 ProxySelector 类忽略了.

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.

这个问题是因为似乎对于 Android 3.x 或更高版本,使用 java.net.ProxySelector 的标准方法似乎没有问题,但不适用于 Android 2.x 版本.这是行为改变了还是我做错了什么?

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?

我们是否应该对 Android 2.x 版本使用全局代理设置?顺便说一下,我们可以通过以下方式读取全局代理设置:

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);

推荐答案

我不认为在 Gingerbread 或 prerhaps Honeycomb 之前有任何对 Wi-Fi 代理的平台级支持.

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


一位在平台这部分工作的 Android 工程师证实,在 Honeycomb 之前,系统没有针对不同网络类型(例如 Wi-Fi)的代理.所以没有官方"的方式来获取 2.x 的 Wi-Fi 代理.


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.

这篇关于用户/开发人员如何为 2.x 版设置 Android 的代理配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆