Android 如何使HttpClient工作得更快?
我有一个应用程序,可以发布到PHP和MySQL服务器,也可以从中获取。我将此函数用于所有GET操作,但大约需要5秒钟。我使用了Android 如何使HttpClient工作得更快?,android,get,apache-commons-httpclient,Android,Get,Apache Commons Httpclient,我有一个应用程序,可以发布到PHP和MySQL服务器,也可以从中获取。我将此函数用于所有GET操作,但大约需要5秒钟。我使用了HttpParams,但它也不起作用 有没有办法让它更快 String responseBine(){ Log.d("destpek wext",""); try{ HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget= new HttpGet(ur
HttpParams
,但它也不起作用
有没有办法让它更快
String responseBine(){
Log.d("destpek wext","");
try{
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget= new HttpGet(urlIndex);
if(logged) {
HttpResponse rs = httpclient.execute(Teketin.httppost, localContext);
EntityUtils.toString(rs.getEntity());
rs = httpclient.execute(httpget, localContext);
EntityUtils.toString(rs.getEntity());
}
responseHandler = new BasicResponseHandler();
String rsp = new String(httpclient.execute(httpget, responseHandler).getBytes("ISO-8859-1"),"UTF-8");
return rsp;
}catch(Exception e){
System.out.println("Exception : " + e.getMessage());
}
Log.d("destpek wext","");
return "";
}
在发现Volley(用于http请求的android库)之前,我一直面临着与您类似的问题。使用截击有助于减少一些秒数
我仍然不满意,因为我的查询大约需要2到3秒,我切换到Node.js+MySQL,它将时间缩短到200毫秒左右 在我发现Volley(用于http请求的android库)之前,我一直面临着与您类似的问题。使用截击有助于减少一些秒数 我仍然不满意,因为我的查询大约需要2到3秒,我切换到Node.js+MySQL,它将时间缩短到200毫秒左右 如果“认为”它很慢,请尝试std
java.net.HttpURLConnection
并比较它们的执行时间如果“认为”它很慢,请尝试stdjava.net.HttpURLConnection
并比较它们的执行时间