使用multipartentity上传视频文件时如何显示进度条

时间:2013-04-29 14:06:22

标签: java android

我使用multipartentity上传视频文件和数据。如何显示进度条并将数组值上传到一个键值?

我使用以下代码:

                DefaultHttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(Call_Server.REPLAY_VIDEO);
                MultipartEntity mpEntity = new MultipartEntity(
                        HttpMultipartMode.STRICT);
                mpEntity.addPart("FILE_UPLOAD", new FileBody(videofile));
                mpEntity.addPart("message_id", new StringBody(recipient_id));
                mpEntity.addPart("recipient_email", new StringBody(recipient_email2));
                totalSize = (int) mpEntity.getContentLength();
                System.out.println(totalSize + ":::::totalSize");
                httppost.setEntity(mpEntity);
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity resEntity = response.getEntity();

2 个答案:

答案 0 :(得分:1)

使用Thread上传数据,并使用runOnUiThread显示进度条。您也可以使用asyn任务。

答案 1 :(得分:0)

好吧,你可以使用Async Task线程功能。