1
votes

I used the same code with only little changes as follows from here :
Downloading File in Android

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
                    "Myproxy", 8080));   
                URL url = new URL(sUrl[0]);  
                HttpURLConnection uc = (HttpURLConnection) url
                    .openConnection(proxy);  
                 uc.connect();  
 int fileLength = uc.getContentLength();  

I am getting following exception for this:
04-12 09:31:42.401: WARN/System.err(5181): java.net.UnknownHostException: Host is unresolved: Myproxy:8080
04-12 09:31:42.405: WARN/System.err(5181): at java.net.Socket.connect(Socket.java:1057)
04-12 09:31:42.405: WARN/System.err(5181): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:62)
04-12 09:31:42.405: WARN/System.err(5181): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
04-12 09:31:42.405: WARN/System.err(5181): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
04-12 09:31:42.409: WARN/System.err(5181): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:884)
04-12 09:31:42.409: WARN/System.err(5181): at com.test.filedownload.FileDownloadActivity$DownloadFile.doInBackground(FileDownloadActivity.java:99)
04-12 09:31:42.413: WARN/System.err(5181): at com.test.filedownload.FileDownloadActivity$DownloadFile.doInBackground(FileDownloadActivity.java:1)
04-12 09:31:42.416: WARN/System.err(5181): at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-12 09:31:42.420: WARN/System.err(5181): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-12 09:31:42.420: WARN/System.err(5181): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-12 09:31:42.420: WARN/System.err(5181): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
04-12 09:31:42.424: WARN/System.err(5181): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
04-12 09:31:42.424: WARN/System.err(5181): at java.lang.Thread.run(Thread.java:1096)

Please help to resolve the same.

Thanks,
Sneha

2

2 Answers

1
votes

This is an issue in Android versions 2.2 that they do not support Proxy
But some phones like LG P500 works with OPera as the brwoser. There is a great detail about this on

http://android-proxy.blogspot.com/

But you can really achive this using proxoid, it is an HTTP proxy for Android.

code.google.com/p/proxoid/

More information can be had from this site.Hope this will help you.

0
votes

java.net.UnknownHostException: Host is unresolved: Myproxy:8080

This says that there is no host named Myproxy in the network. Obtain the proxy name and port and use them in code.