I use the following code to download an image from the Internet and show it in Android ImageView.
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) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return bmp;
}
@Override
protected void onPostExecute(Bitmap result) {
adImg.setImageBitmap(result);
super.onPostExecute(result);
}
}
However, the code leads to an error D/skia(1252): --- SkImageDecoder::Factory returned null.
What could be the problem?
source
share