I'm trying to load an image (JPG) from a url using the following asynctask method.
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
I'm executing this method in onCreate like this
new DownloadImageTask((ImageView) findViewById(R.id.imageView1)).execute(final_url);
But I can't see any image and when I debugged it, I found the value of mIcon11
to be null. What am I doing wrong
PS : The final_url
goes like this
www.website.com/somelink/IMG 005_153.JPG