Usually I used to check for the server different code responses in my RestClient
class using the org.apache.http.HttpStatus
class as the following example:
if (HttpStatus.SC_OK == restClient.getResponseCode()) {
//200 OK (HTTP/1.0 - RFC 1945)
return true;
} else if (HttpStatus.SC_BAD_GATEWAY == restClient.getResponseCode()){
//502 Bad Gateway (HTTP/1.0 - RFC 1945)
return false;
}
But recently the class became deprecated since API level 22 according to the official documentation
This interface was deprecated in API level 22. Please use openConnection() instead. Please visit this webpage for further details.
But using OpenConnection()
method for me does not make any sense.
My Question is: Is there any other way to do the same functionality without needing to hardcode all the code responses by myself within the application?
Thanks in advance.