I want to display an image in an ImageView
which am fetching from a url which I have specified in function. The below is function where am trying to fetch image.
public Bitmap getBitmapFromUrl(String src){
try{
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
Bitmap btmp = BitmapFactory.decodeStream(inputStream);
return btmp;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
The above function is returning null
. The argument src
"http://pyplyn.co/magento2pawan/a.jpg".
Please help me. Where I am going wrong....?