For my current application I collect images from different \"event providers\" in Spain.
Bitmap bmp=null;
HttpGet httpRequest = new HttpGet(strURL);
l
My solution is not to use BitmapFactory.decodeStream() cause the way I look at it, it uses the SKIA decoder and it seems kind of erratic sometimes. You can try something like this.
Bitmap bitmap = null;
InputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new URL(url).openStream(),
IO_BUFFER_SIZE);
final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
copy(in, out);
out.flush();
final byte[] data = dataStream.toByteArray();
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
} catch (......){
}
and for the copy() function
private static void copy(InputStream in, OutputStream out) throws IOException {
byte[] b = new byte[IO_BUFFER_SIZE];
int read;
while ((read = in.read(b)) != -1) {
out.write(b, 0, read);
}
}
and IO_BUFFER_SIZE is a constant integer with the value of 4 * 1024.