Search code examples
androidfacebook-sharefacebook-sdk-4.x

Facebook Share Button disabled


I upgraded the Facebook ShareButton from 4.5.0 to 4.16.1 and now the ShareButton is disabled. I have to support back to Android API level 9, and I just want to use the ShareButton from the Facebook SDK. With 4.5, it was working well.

Here is Facebook Activity from the manifest, I don't use a provider:

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    tools:replace="android:theme" />

FB Button onClick listener:

facebookShareButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentTitle(title)
            .setContentDescription(preview)
            .setContentUrl(Uri.parse(url))
            .build();
        shareDialog.show(content);
    }
});

I initialize the Facebook SDK in my Application class like this:

FacebookSdk.sdkInitialize(this);

Why doesn't it work after upgrading the SDK?


Solution

  • Set your content to share while implementing Share option in Facebook sdk. So set the content while defining the share button.

    ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse("https://developers.facebook.com"))
                .build();
    fbShareButton.setShareContent(content);