Volley JsonObjectRequest 中报告了崩溃,并且恰好在其onErrorResponse
块中。我无法将 web 服务输出更改为测试onErrorResponse
块,调试此代码块很重要。
谁能告诉我如何强制代码进入这部分?
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, "MY_URL", null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// Which code should I add here to force the code to go to onErrorResponse
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
...
// I want to debug this code block
}
});
我试过response = null;
了,onResponse
但它导致了崩溃,它没有去onErrorResponse
。