I have an AsyncTask retrieving content from a website. A few of them in parallel, actually. I've noticed that when I run on a device, rather than the emulator, I will sometimes get a null Bitmap back when I do:

  URLConnection conn = url.openConnection();
  Bitmap image = BitmapFactory.decodeStream(conn.getInputStream());

I tried creating an InputStream locally from the connection, too, with no effect. I suspect the issue is just that sufficient data is not yet available on the URLConnection to satisfy BitmapFactory.decodeStream().

Other than adding a sleep (Thread.sleep), does anyone know of a way to ensure that enough data is available, or otherwise tell BitmapFactory that it should be more patient rather than returning a null Bitmap?

  Thanks...

                            - Chris

--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to