This was the code I have used so far:
URL request = new URL(url);
HttpsURLConnection urlConnection = (HttpsURLConnection) request.openConnection();
urlConnection.setHostnameVerifier(new StrictHostnameVerifier());
However, by API Level 22 StrictHostnameVerifier is deprecated.
This interface was deprecated in API level 22.
Please use openConnection() instead. Please visit this webpage for further details.
The thing is I was already using openConnection
with StrictHostnameVerifier
. I still can use it but I see a deprecated warning on the line
urlConnection.setHostnameVerifier(new StrictHostnameVerifier());
Where is the mistake or what is missing?
PS: Reinventing the wheel and implementing StrictHostnameVerifier
is out of the question apparently.
Edit: Is there anything new regarding new API?