2

I am trying out the FB SDK and I was wondering if it is possible to attach a progress bar while data is being uploaded.

This is a sample example on how FB tells us to do.

ByteArrayOutputStream bos = new ByteArrayOutputStream();
me.compress(Bitmap.CompressFormat.JPEG, 100, bos);
params.putByteArray("picture", bos.toByteArray());
mAsyncRunner.request("me/photos", params, "POST", new SampleUploadListener(), null);

The issue is that you are forced to use a byte array instead of an output stream which you could combine with a progress bar

One alternative I can imagine is to modify Utils.java from the FB SDK but I would rather like to ask if someone had success implementing a progress bar without massing around in the facebook sdk?

Vad1mo
  • 5,156
  • 6
  • 36
  • 65

1 Answers1

3

I found a solution but it involved touching the facebook sdk.

Here is the modified code in Util.java.

Vad1mo
  • 5,156
  • 6
  • 36
  • 65
  • Would be alright if I was to ask a couple of questions about your solution? – Siddharth Lele Dec 03 '12 at 13:57
  • Thank you. I have seen the changes you have made to the `Util.java` class. But what other changes did you make in the Activity where you upload a Photo? – Siddharth Lele Dec 05 '12 at 07:56
  • I only changed the Util.java file.If you want to use it you need to provide a UploadDataProgress to Util prior using it. take a look at the javadoc example at the bottom of util.java. hope this helps – Vad1mo Dec 06 '12 at 13:27
  • Hmm... Let me try that again. Thanks fella. :-) – Siddharth Lele Dec 06 '12 at 13:31