How to use StrictHostnameVerifier through HttpsURLConnection on API level 22 without deprecation?

This was the code I have used so far:

URL request = new URL(url); HttpsURLConnection urlConnection = (HttpsURLConnection) request.openConnection(); urlConnection.setHostnameVerifier(new StrictHostnameVerifier()); 

However, the StrictHostnameVerifier API Level is deprecated.

This interface is deprecated at the API level .
Use openConnection () instead . For more information, visit this web page .

The thing is, I already used openConnection with StrictHostnameVerifier . I can still use it, but I see an outdated warning on the line

 urlConnection.setHostnameVerifier(new StrictHostnameVerifier()); 

Where is the error or what is missing?

PS: It is apparently impossible to StrictHostnameVerifier wheel and implement the StrictHostnameVerifier .


Change What's new about the new API?

+5
source share

All Articles