2010-10-27 68 views
0

我想實現的Android asynchronus HTTP客戶端,我巡航能力與類型不匹配麻煩:的Android asynchronus HTTP客戶端問題

The method execute(HttpUriRequest) in the type HttpClient is not applicable for the arguments (HttpRequest)  

我所做的一切依據本教程:http://blog.androgames.net/12/retrieving-data-asynchronously/

有在AsynchronousSender中找到一個類型 - 私人HttpRequest請求;但我有一個以上發生在仍然問題:

public void run() { 
    try { 
     final HttpResponse response; 
     synchronized (httpClient) { 
      response = getClient().execute(request); //<-- here is that problem 
     } 
     // process response 
     wrapper.setResponse(response); 
     handler.post(wrapper); 
    } catch (ClientProtocolException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
} 

您能否提供什麼?

歡呼聲, /馬辛

回答

2

http://blog.androgames.net/12/retrieving-data-asynchronously/的代碼片段是錯誤的。要修復它,只需將HttpRequest替換爲HttpUriRequest,因爲方法簽名是:HttpClient#execute(HttpUriRequest)。它不應該是任何問題,因爲大多數請求您使用的是HttpUriRequest實例。

+0

不以這種方式工作作爲保護AsynchronousSender(HttpRequest請求...方法期待的請求是HttpRequest類型 – Marcin 2010-10-27 14:37:43

+0

@Marcin:是的,但AsynchronousSender片段是_incorrect_ - 你應該更新它,並用HttpUriRequest替換HttpRequest。 – fornwall 2010-10-27 14:48:07