简体   繁体   中英

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

在此处输入图片说明

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?

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.+' 

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM