Setting up socks proxy in Android emulator
I am writing an android application that needs to access a service via socks proxy. I looked up the android emulator documentation and found out that it supports http proxy but I didn't find any mention about socks proxy. I tried setting up the socks proxy while making the Http connection but that didn't work either. Here is my code snippet:
SocketAddress addr = new InetSocketAddress("socks.foo.com", 1080);
Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr);
URL urlObj = new URL(url);
URLConnection urlConn = urlObj.openConnection(proxy);
InputStream in = urlConn.getInputStream();
Has anyone tried using socks proxy from android em开发者_StackOverflow社区ulator? Any clues/suggestions will be highly appreciated.
Unfortunately, proxy support in Android is very buggy. However, according to the network system properties (get/set via Java, not UI), setting socksProxyHost and socksProxyPort (default: 1080) in your app should work.
Hope this helps,
Phil Lello
精彩评论