共享按钮似乎已禁用 [英] Share button looks disabled

查看:98
本文介绍了共享按钮似乎已禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我已经初始化了sdk:

I already initialize the sdk:

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

    FacebookSdk.sdkInitialize(getApplicationContext());
}

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

I also have the manifest correctly configured like the documentation suggest: 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应用程序?

What could be the problem? Why is the button disabled? Should I implement login functionality in my app? Or I only need to have facebook application on the device?

推荐答案

请参阅com.facebook.share.widget.ShareButtonBase:

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

调用setShareContent以启用shareButton,请尝试:

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

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

实施共享时,您的应用程序不应预填充任何要共享的内容.这与Facebook平台政策不一致,请参阅Facebook平台政策2.3."

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

这篇关于共享按钮似乎已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆