Wai Yan Hein
Wai Yan Hein

Reputation: 14791

How to set description or title to Facebook photo share with PhotoShareContent in Android

I am developing an Android app. In my app, I am integrating Facebook photo share feature. This is my first Android app with Facebook integration. I am able to share photo to user timeline now. But I am having problem with setting description to that image.

This is my Facebook share photo function

 private void sharePhotoToFacebook(){

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

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

        ShareApi.share(content, null);

    }

When photo shared it shows like this in timeline

enter image description here

As you can see there is no description or title. What I want is I want to set title or description. Is there any function can do like below

SharePhotoContent content = new SharePhotoContent.Builder()
                    .addPhoto(photo).setCaption("Description")
                    .build();

How can I set title?

Upvotes: 0

Views: 861

Answers (2)

Dhruvi
Dhruvi

Reputation: 1981

Write setCaption() method as below:

 SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(shareBitmap)
            .setCaption("Description")
            .build();

Note: need to use SDK vertion 4+. Means at least 4.1

compile 'com.facebook.android:facebook-android-sdk:4.+' 

Upvotes: 1

Jitendra A
Jitendra A

Reputation: 1658

As per Facebook Platform Policies (2.3) you cannot set caption from your app. Read this note from documentation.

setCaption(String)

Sets the user generated caption for the photo. Note that the 'caption' must come from the user, as pre-filled content is forbidden by the Platform Policies (2.3).

Upvotes: 1

Related Questions