我已经开发了应用程序,我将音频文件和接收器信息发送到服务器,它的工作很多次上传需要很长时间并导致ConnectionTimeout异常。
我正在使用的代码:
BasicHttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 120000);
HttpConnectionParams.setSoTimeout(httpParameters, 120000);
HttpClient httpClient = new DefaultHttpClient(httpParameters);
postStr = new Gson().toJson(audioBean);
File file = new File(audioBean.getFilePath());
ContentBody contentBody = new FileBody(file, "audio/wav");
MultipartEntity mpEntity = new MultipartEntity();
mpEntity.addPart("audio", new StringBody(postStr));
mpEntity.addPart("file", contentBody);
httpPost.setEntity(mpEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
inputStream = httpResponse.getEntity().getContent();
上面的代码在线程中运行,请告诉我如何提高性能