I am trying to upload a local image to Facebook from my native Android app. I also want the user to be able to add a comment. I have done this:
params.putString("caption", "Caption");
params.putString("description", "Description");
params.putString("picture", Utility.HACK_ICON_URL);
params.putString("name", "name");
String filename = <file_path>
byte[] data = null;
Bitmap bi = BitmapFactory.decodeFile(filename);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
params.putByteArray("photo", data);
Utility.mFacebook.dialog(ScoreAlertBox.this, "feed", params, new UpdateStatusListener());
I see the dialog box with all the fields – icon, caption, decrption. But the picture I want to upload is not there.
As it states in the android sdk dialog documentation:
You can’t pass it a local image, it’s basically just a way to invoke the Feed Dialog which only accepts a url as the picture parameter.
What you should do is upload the image along with the post using requests (or async requests).
Also, if you want to upload an image you’ll need to use
me/photos: User object Photos connection.