我正在嘗試使用Volley打擊休息服務。排球超時錯誤
public class AuthFunctions {
private static final String LOGIN_URL = "http://10.0.2.2:8080/stewayservices/user-management/users/10";
boolean result;
public boolean loginUser(String email,String password){
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,LOGIN_URL,null,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("JsonObject Response",response.toString());
try {
JSONObject user = response.getJSONObject("user");
String firstName = user.getString("firstName");
if (firstName.equals("Lokesh")){
result = true;
}
else{
result = false;
}
} catch (JSONException e) {
Log.d("Web Service Error",e.getMessage());
e.printStackTrace();
}
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("JsonObject Error Response",volleyError.toString());
}
});
request.setRetryPolicy(new DefaultRetryPolicy(500000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
AppController.getInstance().addToRequestQueue(request);
return result;
}
}
但它是給我排球超時錯誤。以下是Logcat
D/JsonObject Error Response﹕ com.android.volley.TimeoutError
請讓我知道如果我做錯了。這是我在stackoverflow關於Android的第一個問題。
你確定你連接到本地主機?您的服務器是否在端口8080處偵聽?你的防火牆關閉了嗎? – mmlooloo 2014-09-23 15:08:45
你有沒有得到任何解決方案? – 2015-11-17 06:52:31