Hi all,
This is an issue that has kept me from doing real work for *a while*
now:
The Task: Read an image from the net (PNG approx. 10kb) and writeit to
the user dir as is.
I'm using a byte array to temporarely store the data, basically like
this:
conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
HttpURLConnection.setFollowRedirects(true);
conn.setChunkedStreamingMode(4096);
conn.connect();
length = conn.getContentLength();
bitmapData2 = new byte[length];
is = new BufferedInputStream(conn.getInputStream());
is.read(bitmapData2);
Then it goes out to a buffered Stream writing to the user dir.
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(name), length);
out.write(bitmapData2, 0, bitmapData2.length);
The Problem: it works - sometimes.
Actually it always works in the emulator, and it usually works when
attaching the debugger to the phone and stepping through the code.
Interestingly it almost always produces corrupt images when running in
'normal mode' - read on the Dev1 via UMTS.
Corrupt images are good at the start of the image, and somewhere in
the middle or to the end, they produce pixel trash. They can't be
decoded to a Bitmap or alike as well.
I'm almost sure it's a HttpURLConnection issue, or at least related to
it.
BTW. the download happens in it's own object instance, but about 10
are triggered in a loop after each other.
I'd appreciate any hints on this.
Cheers.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---