I konw how can get data from web when there is no proxy restricted,like the code below.
But when there is proxy restricted,it doesn't work,and has a exception "Socket is not connected" so I added some codes into the project, InetSocketAddress address = new InetSocketAddress("MY_IP",8080); Proxy myProxy = new Proxy(Proxy.Type.HTTP,address); and change URLConnection ucon = myURL.openConnection(); to URLConnection ucon = myURL.openConnection(myProxy ); and it also needs the username and the password, I use System.setProperty("http.proxyUser", "my_username"); System.setProperty("http.proxyPassword", "My_password"); but it can't get the data from web, So i don't know how to solve this problem,anybody can help me?thank you! public class GetDataFromTheWeb extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); /* We will show the data we read in a TextView. */ TextView tv = new TextView(this); /* Will be filled and displayed later. */ String myString = null; try { /* Define the URL we want to load data from. */ URL myURL = new URL( "http://www.anddev.org/images/tut/basic/ getdatafromtheweb/loadme.txt" "); /* Open a connection to that URL. */ URLConnection ucon = myURL.openConnection(); /* Define InputStreams to read * from the URLConnection. */ InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); /* Read bytes to the Buffer until * there is nothing more to read(-1). */ ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while((current = bis.read()) != -1){ baf.append((byte)current); } /* Convert the Bytes read to a String. */ myString = new String(baf.toByteArray()); } catch (Exception e) { /* On any Error we want to display it. */ myString = e.getMessage(); } /* Show the String on the GUI. */ tv.setText(myString); this.setContentView(tv); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---