我想下载只从JSON页面顶部10个新的更新,,,从JSON页只获得第10个更新directy,不下载整个页面第一,然后选择从它
这下面的代码下载ALLDATA在页面第一然后我选择我想要的,,,但我需要它只从服务器下载最新的10个更新,而无需首先下载整个页面
所以得到的代码尽可能快,因为这个页面是巨大的, 谢谢提前
public String readFeed() {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(
"http://www.zigwheels.com/api/zigtvApi.php?method=data&module=News§ion=News");
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null ) {
builder.append(line);
}
} else {
Log.e(GridViewExampleActivity.class.toString(), "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
我认为有一种方法可以从Android获得它 – Ti7a 2012-02-16 10:37:07
你将如何下载一半的响应? - 不可能 – MKJParekh 2012-02-16 10:42:26
嗯如何使用Gson你试过了吗? – Ti7a 2012-02-16 10:50:19