Share button looks disabled

前端 未结 1 578
温柔的废话
温柔的废话 2021-01-26 13:30

I\'m trying to use a share button in my application, but it looks as if it was disabled:

I already initialize the sdk:

@Override
protected void          


        
1条回答
  •  感情败类
    2021-01-26 14:10

    See 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());
        }
    }
    

    Calling setShareContent to enable the shareButton, try it:

    @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);
    }
    

    Note: 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."

    0 讨论(0)
提交回复
热议问题