0

我已经尝试了很多,但在上传通知中显示进度都没有成功。我可以使用异步任务将数据上传到服务器,但现在我需要将数据上传到服务器并显示在通知栏中,就像我们在 Facebook 中上传图像或视频时一样。

我无法做到这一点。我通过异步上传数据的代码如下。

我在 doInBackGround() 方法中编写了以下代码:

            HttpClient httpClient = new DefaultHttpClient();
            HttpPost postRequest = new HttpPost(
                    "http://********.php?f=setAvatar");
            ByteArrayBody bab = new ByteArrayBody(data, "receipt.jpg");
            // File file= new File("/mnt/sdcard/forest.png");
            // FileBody bin = new FileBody(file);
            File file = new File(ProfileEdit.selectedImagePath);
            MultipartEntity reqEntity = new MultipartEntity(
                    HttpMultipartMode.BROWSER_COMPATIBLE);
            ContentBody cbFile = new FileBody(file, "image/jpeg");
            reqEntity.addPart("im", cbFile);
            reqEntity.addPart("u", new StringBody(USERID));
            reqEntity.addPart("k", new StringBody(KEY));
            reqEntity.addPart("p", new StringBody(pannelId));

            //reqEntity.addPart("id", new StringBody(password));
            //reqEntity.addPart("addExpenseResult", new StringBody(expenceresult));
            postRequest.setEntity(reqEntity);
            HttpResponse response = httpClient.execute(postRequest);
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    response.getEntity().getContent(), "UTF-8"));
            String sResponse;
            StringBuilder s = new StringBuilder();
4

1 回答 1

0

您可以使用RemoteViewandPendingIntent来显示在通知栏上,请参考:http: //developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView

有关详细进度,我需要知道为更新进度条 android 上传了多少字节

于 2012-09-07T09:51:15.350 回答