我有一个奇怪的问题。如果不设置android:targetSdkVersion
我的 http 请求大约需要 1.. 2 秒才能完成,android:targetSdkVersion="16"
例如设置,请求大约需要 20...30 秒!
我在请求开始时登录,我注意到当我启动时Activity
,系统一直处于空闲状态,直到发出请求。
所有请求都在AsyncTask
.
这是代码:
BasicHttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, HTTP_POST_CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParameters, HTTP_POST_SOCKET_CONNECTION_TIMEOUT);
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Accept-Encoding", "gzip");
HttpClient httpClient = new DefaultHttpClient(httpParameters);
...
HttpResponse response = httpClient.execute(request);
谢谢!