I've tracked the problem down to a rather odd place:  Handler.

The first post networking call is kicked off on a separate thread when
the user clicks a button.  When this call returns its result, a
Handler is spawned to update the UI and also download the image data
for display in a newly created ImageView.  If the file download Thread
is started from within the Handler's Runnable, I get the error
described above.  HOWEVER if I spawn the thread outside the Handler's
Runnable, then all works well.  Sadly...I need to make the call from
with the Handler is that's where my ImageView is created.

SO I'm stuck at the moment.  I don't see why spawning a Thread inside
a Handler's Runnable callback should be a problem as I should then be
on the main thread. Curiously I can use Drawable.createFromStream(new
URL(url).getContent()) to create my Drawable without a problem.  I
guess Android's own code knows a workaround to my bug.  However I
actually need the image data for storage to a file first so that
Drawable solution won't work for me.

Time to dig into Android's code to see why Drawable.createFromStream
(new URL(url).getContent()) works inside the Handler while mine
doesn't.

Any other thoughts?

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to