Android decoder->decode returned false for Bitmap download -


i've started getting

debug/skia(xxxx): --- decoder->decode returned false  

issue on few profile images facebook use in imageviews. work perfectly, every once in while discover 1 never works.

i compiling application against android 1.6 backward compatibility reasons.

i did digging , discovered number of threads on issue. i'm using flushedinputstream discussed here: http://code.google.com/p/android/issues/detail?id=6066

bitmap b = bitmapfactory.decodestream(new flushedinputstream(is)); imageview.setimagebitmap(b); 

here's example that's causing me trouble: http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs269.snc3/23132_639284607_390_q.jpg

can check out image , me figure out what's causing trouble?

there bug in flushedinputstream(is). fails on slow connections can try magical code fix it.

bitmap b = bitmapfactory.decodestream(new flushedinputstream(is)); imageview.setimagebitmap(b); 

create static class outside method

 static class flushedinputstream extends filterinputstream {         public flushedinputstream(inputstream inputstream) {             super(inputstream);         }          @override         public long skip(long n) throws ioexception {             long totalbytesskipped = 0l;             while (totalbytesskipped < n) {                 long bytesskipped = in.skip(n - totalbytesskipped);                 if (bytesskipped == 0l) {                     int b = read();                     if (b < 0) {                         break;  // reached eof                     } else {                         bytesskipped = 1; // read 1 byte                     }                 }                 totalbytesskipped += bytesskipped;             }             return totalbytesskipped;         }     } 

and here go.. not have problem.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -