1

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??

max
  • 263
  • 2
  • 16

1 Answers1

1

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

Community
  • 1
  • 1
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
  • its all working fine.But when i use .setContentUrl only the given playstore image and text are appearing and not the defined text.Why its so?? – max Dec 28 '16 at 08:49
  • can u tell me what field? setContentTitle or setContentDescription? – rafsanahmad007 Dec 28 '16 at 09:13
  • Both setContentTitle and setContentDescription are not getting .Instead of these The post shows a single text which is given in the playstore app name. – max Dec 28 '16 at 09:21
  • now this is deprecated.. see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations – Lorenzo Barbagli May 27 '17 at 15:15