I am trying to GET a Bitmap image from a URL.
(Example: https://cdn.bulbagarden.net/upload/9/9a/Spr_7s_001.png)
But there seems to be a problem with the connection.connect()
line, that I can't figure out.
I have allowed internet access in the app.
public static Bitmap getBitmapFromURL(String src) {
HttpURLConnection connection = null;
InputStream inputStream = null;
try {
URL url = new URL(src);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
}
return BitmapFactory.decodeStream(inputStream);
}