Android: Unable to make httprequest behind firewall

末鹿安然 提交于 2019-12-01 01:24:53

See if this little beastie will help you. It may be that you need this in the emulator image you are running.

http://openhandsetmagazine.com/2007/11/tips-howto-connect-android-emulator-behind-proxy/

You can set proxy in your code too.

   public void setProxy(DefaultHttpClient httpclient) {  
           final String PROXY_IP = "<insert your IP here>";  
            final int PROXY_PORT = <insert_PROXY_PORT#>;  

            httpclient.getCredentialsProvider().setCredentials(  
                    new AuthScope(PROXY_IP, PROXY_PORT),  
                    new UsernamePasswordCredentials(  
                            "username", "password"));  

           HttpHost proxy = new HttpHost(PROXY_IP, PROXY_PORT);  

           httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,  
                   proxy);  


       }  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!