简体   繁体   中英

Android Application Internet Access Behind Proxy

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

I have tried setting 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 thes e 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM