I have an image URL. I want to display an image from this URL in an ImageView but I am unable to do that.
How can this be achieved?
loadImage("http://relinjose.com/directory/filename.png");
Here you go
void loadImage(String image_location) {
URL imageURL = null;
if (image_location != null) {
try {
imageURL = new URL(image_location);
HttpURLConnection connection = (HttpURLConnection) imageURL
.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);// Convert to bitmap
ivdpfirst.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
} else {
//set any default
}
}