Android decoder->decode returned false for Bitmap download

前端 未结 7 1684
不知归路
不知归路 2020-11-30 06:02

I\'ve started getting a

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

issue on a few profile images from Facebook that I use in

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 06:13

    The source code from this ImageDownloader.java is a good orientation. It has a bug fix which addresses the Issue 6066 by providing a patched FlushedInputStream class.

    Another thing which you might want to take care of, is to execute the decoding in the same thread as the HTTP request was executed:

    @Override
    protected Bitmap doInBackground(String... url) {
         // execute HTTP GET request and decode response
         ...
         return bitmap
    }
    
    
    @Override
    protected void onPostExecute(Bitmap result) {
         imageView.setImageBitmap(result);
    }
    

    I had done the decoding in the onPostExecute(), which is executed in the UI thread, and it would not work anymore, giving me the same error.

提交回复
热议问题