我可以在Eclipse的Android模拟器中将它连接到我的localhost Web服务器页面http://localhost或在http://127.0.0.1?
我已经尝试过了,但是仿真器仍然像Google搜索localhost一样接受我的请求,或者更糟糕的是它说我的网络服务器正常运行时没有找到该页面.
我正试图用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());
}
}); …Run Code Online (Sandbox Code Playgroud)