A. Petrizza
A. Petrizza

Reputation: 3350

Sharing photo on FB's latest apk

I am trying to share a photo on Facebook.

I have login working, and the share dialog will pop up with sharelinkcontent but not with photo.

It will not pop up at all, but it is running and hitting this code.

Here is my code:

if (ShareDialog.canShow(SharePhotoContent.class)) {
//            ShareLinkContent linkContent = new ShareLinkContent.Builder()
//                    .build();
//            shareDialog.show(linkContent);


        Bitmap icon = BitmapFactory.decodeResource(this.getResources(),
                R.drawable.common_plus_signin_btn_text_light);

        SharePhoto photo = new SharePhoto.Builder()
                .setBitmap(icon)
                .build();

        SharePhotoContent photoContent = new SharePhotoContent.Builder()
                .addPhoto(photo)
                .build();

        shareDialog.show(photoContent);

    }

Upvotes: 0

Views: 138

Answers (1)

fdelafuente
fdelafuente

Reputation: 1122

Facebook SDK's versions 4.0+ have changed the way you can share content on facebook. For photos, you need to use PhotoShareContent.
For links, the ShareLinkContent.

A requirement of the SharePhotoContent is that you must have installed the native faceboook app in order to share photos.

From Facebook Doc

Photos

People can share photos from your app to Facebook with the Share Dialog or with a custom interface.

  • The photos must be less than 12MB in size
  • People need the native Facebook for Android app installed, version 7.0 or higher

On the other hand, to share a link is not necessary the facebook app, that's why your code works when you use ShareLinkContent

Upvotes: 1

Related Questions