5

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?

guness
  • 6,336
  • 7
  • 59
  • 88
  • 1
    My guess is that in order to make people stop using the Apache HttpClient, they deprecated every class within that package, including the `HostnameVerifier`s - even though they implement the interface both used by HttpUrlConnection *and* HttpClient... Personally, I'd just suppress the deprecation warning. – EpicPandaForce May 13 '15 at 13:44

0 Answers0