我建立一个从断绝Android中使用JSON获取数据的应用程序。有喜欢的3000条记录是获取和加载似乎相当缓慢。在code,以获取数据如下 -
I am building an app that is fetching data from sever using JSON in android. There are like 3000 records that are fetched and the loading seems rather slow. The code to fetch data is as follows -
public static String executeHttpGet(String url) throws Exception {
BufferedReader in = null;
try {
HttpClient client = getHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
// in = new BufferedReader(new InputStreamReader(response.getEntity()
// .getContent()));
in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent(), "UTF-8"));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String result = sb.toString();
return result;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e("log_tag", "Error converting result " + e.toString());
e.printStackTrace();
}
}
}
有没有什么可以做,以加快取?先谢谢了。
Is there anything that can be done to speed up the fetching? Thanks in advance.
见下图: -
有关快速反应,你必须使用改造。
For quick response you have to use retrofit.
http://instructure.github.io/blog /十二分之二千〇一十三/ 09 /抽射-VS-改造/
上一篇:的WinForms RichTextBox的:如何在框TextChanged进行格式化?如何在、WinForms、RichTextBox、TextChanged
下一篇:java.lang.IllegalStateException:不适用于活动的onCreate()之前系统服务不适用于、系统、lang、java