2013-01-11 60 views
0

我设置了下面的Http请求。但为什么这个HTTP请求没有响应?为什么这个http请求没有响应?

AsyncHttpClient client = new AsyncHttpClient(); 
Log.d("click","click"); 
     client.get("http://www.baidu.com", new AsyncHttpResponseHandler() 
     { 
      @Override 
      public void onSuccess(String response) { 
       Log.d("response",response); 
       //System.out.println(response); 
      } 
     }); 

任何人的帮助是非常感谢。

+1

实现onFailure方法并打印出响应字符串 – Infinity

回答

1

实施其他AsyncHttpResponseHandler方法,看看会发生什么:

client.get("http://www.baidu.com", new AsyncHttpResponseHandler() 
{ 
    static final String TAG = "AsyncHttpResponseHandler"; 
    @Override 
    public void onSuccess(String response) { 
     Log.d(TAG, "Success: " + response); 
    } 

    @Override 
    public void onFailure(Throwable e, String response) { 
     Log.d(TAG, "Failure: " + response, e); 
    } 

    @Override 
    public void onFinish() { 
     Log.d(TAG, "Finish"); 
    } 
});