Unable To Post An Image From Drawable To Facebook
Solution 1:
Publish feed will work only with url to image.
See picture
property under feed documentation: https://developers.facebook.com/docs/reference/dialogs/feed/
If you want to publish image from your memory (like drawable folder) then you need to use: Request.newUploadPhotoRequest()
Beside this, you can use this simple open source library that supports SDK 3.5 for doing actions like publish photo, feed and so on in a very simple way: https://github.com/sromku/android-simple-facebook
UPDATE
Option 1
You can use Request.newUploadPhotoRequest()
, but this method doesn't allow you to add any additional property except the image itself.
Bitmapbitmap= BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launcher);
Request.newUploadPhotoRequest(Session.getActiveSession(), bitmap , newRequest.Callback()
{
@OverridepublicvoidonCompleted(Response response)
{
// ... handle the response...
}
});
Option 2
If you want to add additional properties to the image like description, then do almost the same but with raw graph api call. The facebook implementation of Request.newUploadPhotoRequest()
does exactly the same but without setting additional properties.
Bitmapbitmap= BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launcher);
Bundleparams=newBundle();
params.putParcelable("picture", bitmap);
params.putString("message", "This is the description of the image");
params.putString("place", "1235456498726"); // place id of the imageRequestrequest=newRequest(session, "me/photos", bundle, HttpMethod.POST, newRequest.Callback()
{
@OverridepublicvoidonCompleted(Response response)
{
// ... handle the response...
}
});
RequestAsyncTasktask=newRequestAsyncTask(request);
task.execute();
Post a Comment for "Unable To Post An Image From Drawable To Facebook"