I am using volley
to download some data from a server with PHP
but I have the problem that when the server is not available volley
it returns an error:
public void onErrorResponse(VolleyError volleyError) {
String message ="";
String message ="";
if (volleyError instanceof NetworkError) {
message = "Error Network!";
} else if (volleyError instanceof ServerError) {
message = "The server could not be found. Please try again after some time!!";
} else if (volleyError instanceof ParseError) {
message = "Parsing error! Please try again after some time!!";
} else if (volleyError instanceof NoConnectionError) {
message = "Cannot connect to Internet...Please check your connection!";
} else if (volleyError instanceof TimeoutError) {
message = "Connection TimeOut! Please check your internet connection.";
}
Toast.makeText(getApplicationContext(),message,Toast.LENGTH_LONG).show();
}
Toast.makeText(getApplicationContext(),message,Toast.LENGTH_LONG).show();
}
I have tried this way but it always tells me Error network, that is, the first if, but I do have Internet.
NetworkError:
If you enter at this point:
indicates:
ServerError :
To detect if the server is not available or returns a 500 series error (
ServerError
)should go here: