Sorry to ping again, but does anyone have any idea how to take an InputStream from a URLConnection, and make enough data available so that BitmapFactory will either (a) wait for the data, or (b) have all data already available to it?
I looked at all of the various classes in/around InputStream, and I didn't see any way to "preload" it. Do I need to get the content all by myself? - Chris On Apr 10, 2010, at 10:03 PM, Chris Ross wrote: > 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... -- 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.