How an Android app decides whether they want to use a network proxy or not

I did some testing with wifi proxy settings on Motorola Xoom with Android 3.2. So, first of all, this is a big step forward compared to 2.x. Now, if you install a proxy server, most applications automatically receive it (in 2.x only the built-in browser is used). So I tried things like yahoo finance, bloomberg, etc., and they all went through a proxy. What I do not get is some browsers, such as firefox, Opera, will not go through the proxy. Any idea how they did it. Basically in my application, how can I decide if I want to use a proxy server or try to connect directly. Based on my testing, if we are not doing anything special, proxies are used by default. So what do I need to do to let my browser skip proxies like Firefox / Opera?

Thanks!

+1
source share
1 answer

On devices with API version> = 11 (Android 3.1 and higher), the answer is here:

Android Proxy Confuses Documentation Resources

You can simply call the getDefault () method from the ProxySelector class and get the default Android ProxySelector default implementation.

ProxySelector defaultProxySelector = ProxySelector.getDefault(); Proxy proxy = null; List<Proxy> proxyList = defaultProxySelector.select(uri); if (proxyList.size() > 0) { proxy = proxyList.get(0); Log.d(TAG, "Current Proxy Configuration: " + proxy.toString()); } 

I think that some Android applications (you said Opera and Firefox) just do not perform this check, but they implement some of their own proxy server functions without worrying about how the system works.

+7
source

Source: https://habr.com/ru/post/1382662/


All Articles