开发者

Android Application Internet Access Behind Proxy

开发者 https://www.devze.com 2023-01-17 17:30 出处:网络
I have an android application(Android 2.2) accessing internet behind proxy. I have tried settin开发者_Python百科g an APN with proxy host & port and it works fine in emulator browser.

I have an android application(Android 2.2) accessing internet behind proxy.

I have tried settin开发者_Python百科g an APN with proxy host & port and it works fine in emulator browser. But the application fails to connect to internet.

I have also tried command line option of -http-proxy, it doesn't work.

Can somebody help me with it?


set Permission for your APP to access the Internet on your Manifest File.like..

<uses-permission android:name="android.permission.INTERNET" />

For More Info check the ApiDemos APP and these Documentation


After so many days of struggling, I found out there is an issue on android when accessing the https using apache HTTP client with proxy.

Refer this for issue.http://code.google.com/p/android/issues/detail?id=2690

The fix for the problem is here.


String myProxy=Proxy.getDefaultHost() ;
        int myPort=Proxy.getDefaultPort();
        HttpHost proxy = new HttpHost(myProxy,myPort,"http");
        client.getParams().setParameter (ConnRoutePNames.DEFAULT_PROXY, proxy); 

try giving this within your java file. before that change your proxy settings in emulator!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号