更新时间:2022-11-27 11:34:29
阅读从Web服务的内容。
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet();
URI uri = new URI("http://www.am4b&lat... ...");
httpGet.setURI(uri);
HttpResponse httpResponse = httpClient.execute(httpGet);
InputStream jsonfile = httpResponse.getEntity().getContent();
bufferedReader = new BufferedReader(new InputStreamReader(jsonfile));
String ligneLue = bufferedReader.readLine();
while(ligneLue !=null)
{
stringBuffer.append(ligneLue);
stringBuffer.append("\n");
ligneLue = bufferedReader.readLine();
}
jsontext = stringBuffer.toString();
分析抗衡的JSON
JSONObject response = new JSONObject(jsontext);
JSONArray hotspots = new JSONArray(response.getString("hotspots"));
for (i=0; i<hotspots.length(); i++)
{ JSONObject hotpost = hotspots.getJSONObject(i);
monPOI = new POIObject(hotpost);
//Log.d("JSON_Import", "** " + i + monPOI.verbose());
POIs.add(monPOI);
}