传递详细信息给排球内线

问题描述:

这个答案应该很简单,但我需要帮助。 我添加了一个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); 
} 
+0

当你把什么错误说那里的网址?当你有错误时,你读过IDE的建议吗? –

+0

IDE建议使passURL'最终',我认为这将解决它。 – CSchwarz

+0

正确。并做到了? –

为了扩大对@捷尔的回答让passurl最后例如method(final String passurl)

如果我给你正确的

new Response.ErrorListener() 
{ 
    @Override 
    public void onErrorResponse (VolleyError error){ 
    if (error.getMessage() != null) { 
     Log.d(TAG, "url: " + passurl + " error " + error.getMessage()); 
    } 
    } 
}