You may want to try adding the following line before "return bmp;"

    con.disconnect()


--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.



On Apr 23, 6:29 am, Alex <[email protected]> wrote:
> I have written a method, like this
> private Bitmap getBitmapFromUrl(String urlString)
> {
>   try  {
>     URL url = new URL(urlString);
>     HttpURLConnection con = (HttpURLConnection)url.openConnection();
>     InputStream is = con.getInputStream();
>     Bitmap bmp = BitmapFactory.decodeStream(is);
>     return bmp;
>   }catch(Exception e)
>   {
>     return null;
>   }
>
> };
>
> When I call this method continuously in a thread, it returns a valid
> bitmap only at the first call, as for the following call, LogCat would
> report "jpeg error 20 Improper call to JPEG library in state".
>
> Actually, I think the problem is because of the connection error,
> since when I debug the application, the inputstream seems invalid.
>
> Is there anyone know what the problem is it?
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to