0
這個答案應該很簡單,但我需要幫助。 我添加了一個URL調用Volley和錯誤響應我需要知道該錯誤的URL是什麼,我可能有50個不同的URL在單個隊列中,例如,所以我想知道50中哪一個返回了錯誤。傳遞詳細信息給排球內線
這裏是我的代碼:
public void upload(String passurl) {
StringRequest stringRequest;
// Request a string response
stringRequest = new StringRequest(Request.Method.GET, passurl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG,"Send successful");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//***I want the URL that failed here!
error.printStackTrace();
}
});
stringRequest.setRetryPolicy(new DefaultRetryPolicy(30000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Add the request to the queue
stringRequest.setShouldCache(false);
stringRequest.setTag(TAG);
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(this.getApplicationContext());
mRequestQueue.start();
}
mRequestQueue.getCache().clear();
mRequestQueue.add(stringRequest);
}
當你把什麼錯誤說那裏的網址?當你有錯誤時,你讀過IDE的建議嗎? –
IDE建議使passURL'最終',我認爲這將解決它。 – CSchwarz
正確。並做到了? –