Android SkImageDecoder::Factory returned null Error

前端 未结 1 1018
我在风中等你
我在风中等你 2020-12-03 12:19

I\'m trying to load an image from URL to an ImageView but the error occurs: SkImageDecoder::Factory returned null. How can I fix it?

here is my code :



        
相关标签:
1条回答
  • 2020-12-03 13:17

    Solved. Change the code to this.

    @Override
            protected Bitmap doInBackground(String... params) {
                // TODO Auto-generated method stub
                String urlStr = params[0];
                Bitmap img = null;
    
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet(urlStr);
                HttpResponse response;
                try {
                    response = (HttpResponse)client.execute(request);           
                    HttpEntity entity = response.getEntity();
                    BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
                    InputStream inputStream = bufferedEntity.getContent();
                    img = BitmapFactory.decodeStream(inputStream);
                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return img;
            }
    
    0 讨论(0)
提交回复
热议问题