首先,我想告诉大家我已经搜索了所有相关的线程,并提出了一个查询“与Volley库同步POST方法”,但我无法取得任何成功。
我试图通过调用volley synch方法获取服务器响应(这是我们的本地服务器),并且我得到Timeout Exception ... :(,
RequestFuture<JSONObject> future = RequestFuture.newFuture();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(params), future, future);
mRequestQueue.add(request);
try
{
JSONObject response = future.get(10, TimeUnit.SECONDS);
return (response.toString());
//VolleyLog.v("Response from server: %s", response.toString());
}
catch (InterruptedException e)
{
//exception log message
return("Interruption Exception");
}
catch (ExecutionException e)
{
//exception log message
return("Execution Exception");
}
catch (TimeoutException e)
{
e.printStackTrace();
return("Timeout Exception");
}
有人请指导我这是什么问题吗?