2017-08-15 72 views
-1
HttpAsyncRequest request = new HttpAsyncRequest(
           MapsActivity.this, 
           Constant.BaseUrl, 
           HttpAsyncRequest.RequestType.GET, 
           new MarkerParser(), listener); 
request.addParam("array",arr); //this is not working 
request.execute(); 

工作,我想發送經緯度給我使用的HTTP請求的服務器的ArrayList的,但我們只能通過發送字符串。如何發送latlng的數組列表?發送ArrayList的服務器不與AsyncHttp

+0

是什麼庫,到底是什麼? –

+0

http://loopj.com/android-async-http/這是我正在使用的庫@MatiasOlocco –

+0

爲什麼你不使用'RequestParams'作爲文檔說的? –

回答

0

這是我如何將latlng的arraylist傳遞給JSONARRAY,然後轉換成字符串然後發送到服務器。

JSONArray pointsinjsonarray = new JSONArray();

    for(int i=0;i<arraylistofmarkers.size();i++) { 
         try { 
          pointsinjsonarray.put(i,arraylistofmarkers.get(i)); 

         } catch (JSONException e) { 
          e.printStackTrace(); 
         } 

pointsinjsonarray.toString();

0

我不知道你在哪裏得到那個類(也許它是你自己的......),正如我在我的評論中所述。在文檔裏,你們應該做到以下幾點:

RequestParams params = new RequestParams(); 
params.put("array", arr); 
AsyncHttpClient client = new AsyncHttpClient(); 
//listener is an instance of AsyncHttpResponseHandler 
client.get(Constant.BaseUrl, listener, params); 

來源:http://loopj.com/android-async-http/