3
我使用下面的代碼從互聯網上下載圖像並在Android中顯示它ImageView
。D/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
錯誤。
可能是什麼問題?
圖像無法正常decoded.make確保您的圖片可以到URL路徑 –
被你的網址正確嗎? – Raghunandan
網址確定無誤,圖像在路徑中可用。 –