Android: Unable to make httprequest behind firewall

后端 未结 2 1178
栀梦
栀梦 2021-01-07 08:16

The standard getUrlContent works welll when there is no firewall. But I got exceptions when I try to do it behind a firewall.

I\'ve tried to set \"http proxy server

相关标签:
2条回答
  • 2021-01-07 08:26

    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/

    0 讨论(0)
  • 2021-01-07 08:32

    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);  
    
    
           }  
    
    0 讨论(0)
提交回复
热议问题