在Android模拟器中设置socks代理
我正在编写一个 Android 应用程序,需要通过 socks 代理访问服务。我查找了 android 模拟器文档 并发现它支持 http 代理但我没有找到任何关于袜子代理的提及。我尝试在建立 Http 连接时设置袜子代理,但这也不起作用。这是我的代码片段:
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();
有没有人尝试过使用 android 模拟器的袜子代理?任何线索/建议将不胜感激。
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 emulator? Any clues/suggestions will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是,Android 中的代理支持存在很多问题。但是,根据网络系统属性(通过Java获取/设置,不是UI),设置socksProxyHost 和
您的应用程序中的socksProxyPort(默认值:1080)应该可以工作。
希望这有帮助,
菲尔·莱洛
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