I want to know if the server is down or not when i do a request, basicly i am trying to do a simple register(it already works) but if put the nodeJS server down when i click the register it doesn't appear any error on my toast, i tried to follow some answers that i found but nothing works
Here is what i tried:
public void notifyError(String requestType,VolleyError error) {
String body;
if(error.networkResponse.data!=null) {
String statusCode = String.valueOf(error.networkResponse.statusCode);
try {
if (error instanceof NetworkError) {
Log.d("internet","nao tem internet ligada");
}
else if (error instanceof ServerError) {
Log.d("internet","The server could not be found. Please try again after some time!!");
}
body = new String(error.networkResponse.data,"UTF-8");
JSONObject jsonObj = new JSONObject(body);
Log.d("body",String.valueOf(jsonObj.get("message")));
showToast(String.valueOf(jsonObj.get("message")));
} catch (UnsupportedEncodingException e) {
showToast("You need to connect to the internet!");
} catch (JSONException e) {
Log.d("json:","problems decoding jsonObj");
}
}
For any question related to how i construct the volley example i followed this thread
The messages inside the NEtwork error and serverError never show, any tip?