Hi, i got the same issue, i used POST method, got the same exception.
On 20 août, 06:08, brad <[EMAIL PROTECTED]> wrote: > Hi, > > I had used java.net.HttpURLConnection or java.net.Socket to get a > image viaHTTPprotocol. > But it always got "java.net.SocketException : unknown error" message. > Why??? > Does 0.9-SDK support network operation??? > Thanks in advance. > > Brad. > > my code: > Bitmap bitmap = null; > InputStream in = null; > int response = -1; > try { > //we use URLConnection because it's > anticipated that it is lighter- > weight than HttpClient > //NOTE: At this time, neither properly > support connect timeouts > //as a consequence, this implementation will > hang on a failure to > connect > URL url = new URL("http://10.0.2.2/test.jpg"); > URLConnection conn = url.openConnection(); > if (!(conn instanceof HttpURLConnection)) > throw new > IOException("Not anHTTPconnection."); > HttpURLConnection httpConn = > (HttpURLConnection) conn; > httpConn.setAllowUserInteraction(false); > //httpConn.setConnectTimeout(CONNECT_TIMEOUT); > //httpConn.setReadTimeout(SOCKET_TIMEOUT); > httpConn.setInstanceFollowRedirects(true); > httpConn.setRequestMethod("GET"); > httpConn.connect(); // <-- exceptoin occurs > at this line > response = httpConn.getResponseCode(); > if (response == HttpURLConnection.HTTP_OK) { > in = httpConn.getInputStream(); > bitmap = > BitmapFactory.decodeStream(in); > } > } finally { > if (in != null) try { > in.close(); > } catch (IOException e) { > /* ignore */ > } > } --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---