Android issue Text along with image,hashtag sharing using facebook sdk

1.7k Views Asked by At

I need to share image along with the text and pre-populated hash tag to facebook. So i integrate facebook SDK for sharing.For that i used the following code:-

SharePhoto photo = new SharePhoto.Builder()
                        .setBitmap(image)

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

                        .setShareHashtag(new ShareHashtag.Builder()
                                .setHashtag("#loveloqal").build())
                        .build();

Now i can populate the image and hash tag But can't populate the text.i heard that the posting userdefined posts are against the privacy policy of facebook.Is there any way to do this.I searched a lot.Can someone help me to find a solution??

1

There are 1 best solutions below

4
On

you can use SharelinkContent https://developers.facebook.com/docs/reference/android/current/class/ShareLinkContent/

It is added in facebook-android-sdk:4.6.0

 <provider
        android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true" />

To use it:

  1. Create a provider in your manifest.xml file like above

     ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
                .setContentTitle("Your Title")
                .setContentDescription("Your Description")
                .setContentUrl(Uri.parse("URL[will open website or app]"))
                .setImageUrl(Uri.parse("image or logo [if playstore or app store url then no need of this image url]"))
                .build();
    
  2. create Sharelink content with data and image

  3. Show the dialog.

    ShareDialog.show(ShowNavigationActivity.this,shareLinkContent);

After some research there is i found that SharelinkContent has bugs in facebook sdk

see this: Description not shown in Facebook ShareDialog

you can use Open Graph instead... see this:

1.https://developers.facebook.com/docs/sharing/opengraph/android

And

  1. How to share Title and description from android to facebook using facebook sdk 4.1.2

Hope it helps u...