I am trying to get an image from a URL which starts with HTTPS. I keep getting the Hostname was not verified exception.
I took a look at this question java.io.IOException: Hostname was not verified but didn't understood how to make it work.
Is there any way I can allow all hostnames?
Here's the code thats giving me trouble:
public Drawable drawableFromUrl(String url) {
Bitmap x;
HttpURLConnection connection;
try {
connection = (HttpURLConnection) new URL(url).openConnection();
connection.connect();
InputStream input = connection.getInputStream();
x = BitmapFactory.decodeStream(input);
return new BitmapDrawable(x);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
return null;
}
return null;
}
Thanks in advance for your help