共享按钮看起来已禁用

Share button looks disabled

我正在尝试在我的应用程序中使用共享按钮,但它看起来好像被禁用了:

我已经初始化了sdk:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FacebookSdk.sdkInitialize(getApplicationContext());
}

我也像文档中建议的那样正确配置了清单: https://developers.facebook.com/docs/android/getting-started

视图中的按钮是这样的:

<com.facebook.share.widget.ShareButton
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="@string/share"
              android:id="@+id/share_on_fb_button"
              bind:onClick="shareOnFBButtonClick"/>

可能是什么问题?为什么按钮被禁用?我应该在我的应用程序中实现登录功能吗?或者我只需要在设备上安装 facebook 应用程序?

参见com.facebook.share.widget.ShareButtonBase:

/**
 * Sets the share content on the button.
 * @param shareContent The share content.
 */
public void setShareContent(final ShareContent shareContent) {
    this.shareContent = shareContent;
    if (!enabledExplicitlySet) {
        internalSetEnabled(canShare());
    }
}

正在调用setShareContent开启shareButton,试一试:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.activity_main);

    ShareButton fbShareButton = (ShareButton) findViewById(R.id.share_on_fb_button);
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentUrl(Uri.parse("https://developers.facebook.com"))
            .build();
    fbShareButton.setShareContent(content);
}

注意: https://developers.facebook.com/docs/sharing/android

"When you implement sharing, your app should not pre-fill any content to be shared. This is inconsistent with Facebook Platform Policy, see Facebook Platform Policy, 2.3."