【发布时间】:2017-05-20 12:20:10
【问题描述】:
我想知道当我发出请求时服务器是否关闭,基本上我正在尝试做一个简单的注册(它已经工作)但是如果当我单击注册时将 nodeJS 服务器关闭它不会在我的吐司上出现任何错误,我试图按照我找到的一些答案进行操作,但没有任何效果
这是我尝试过的:
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");
}
}
关于我如何构建凌空示例的任何问题,我都遵循了这个thread
NEtwork error 和 serverError 中的消息从不显示,有什么提示吗?
【问题讨论】:
标签: java android android-volley