我在Android上有:
HttpResponse httpGetResponse = client.execute(request);
...
Log.e("HEADER: ", httpGetResponse.getStatusLine().toString() );例如,我execute一个HttpGet请求,然后对响应做一些事情。然而,我想以某种方式将它放在一个单独的线程中,这样UI线程就不会在服务器响应时冻结。你认为最好的方法是什么?
桑斯克!
发布于 2012-05-26 22:32:32
将请求包装到AsyncTask中,并在doInBackground中执行实际的请求。由于您可能必须在UI线程上使用输出,因此您可能应该从doInBackground中返回所需的数据,并在AsyncTask中使用postExecute选项。
https://stackoverflow.com/questions/10766286
复制相似问题