2014-02-24 51 views
3

我使用下面的代碼從互聯網上下載圖像並在Android中顯示它ImageViewD/skia(1252):--- SkImageDecoder :: Factory返回null錯誤

private class DownloadImage extends AsyncTask<String, Void, Bitmap> { 

    @Override 
    protected Bitmap doInBackground(String... arg) { 
     Bitmap bmp = null; 
     try { 
      URL url = new URL(arg[0]); 
      bmp = BitmapFactory.decodeStream(url.openConnection() 
        .getInputStream()); 

     } catch (MalformedURLException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return bmp; 

    } 

    @Override 
    protected void onPostExecute(Bitmap result) { 
     adImg.setImageBitmap(result); 
     super.onPostExecute(result); 
    } 
} 

但是,代碼導致D/skia(1252): --- SkImageDecoder::Factory returned null錯誤。

可能是什麼問題?

+0

圖像無法正常decoded.make確保您的圖片可以到URL路徑 –

+0

被你的網址正確嗎? – Raghunandan

+0

網址確定無誤,圖像在路徑中可用。 –

回答

0

我的理由是爲什麼會發生這種情況。 主要問題,我發現是:

  • URL - 可能需要額外的權限來訪問圖像。

  • URL-它需要HTTP GET方法來訪問圖像

  • 的圖像是大

相關問題