0

I have tried a lot but have been unsuccessful in displaying progress in notification at uploading. I am able to upload data to server using Asynch Task but now I need to upload the data to server and display in notification bar, like when we upload image or video in Facebook.

I am unable to do this. My code for uploading data through asynch are below.

I write below code in doInBackGround() method:

            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();
halfer
  • 19,824
  • 17
  • 99
  • 186
SRam
  • 2,832
  • 4
  • 45
  • 72

1 Answers1

0

You can use RemoteView and PendingIntent to display on notification bar, please refer to: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView

for detail progress, I need know how much bytes has been uploaded for update a progress bar android

Community
  • 1
  • 1
sam.wang.0723
  • 321
  • 1
  • 7