Thank you guys.
On 20 août, 09:51, Pau <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You must insert the next Uses Permission in AndroidManifest.xml:
>
> <uses-permission android:name="android.permission.INTERNET"></uses-
> permission>
>
> Pau
>
> On 20 ago, 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---