Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android “共享”按钮看起来已禁用_Android_Facebook_Share_Facebook Sdk 4.x - Fatal编程技术网

Android “共享”按钮看起来已禁用

Android “共享”按钮看起来已禁用,android,facebook,share,facebook-sdk-4.x,Android,Facebook,Share,Facebook Sdk 4.x,我试图在应用程序中使用共享按钮,但它看起来好像已被禁用: 我已经初始化了sdk: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); } 我还正确配置了清单,如文档所示: 视图中的按钮如下所示: <com.faceboo

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

我已经初始化了sdk:

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

    FacebookSdk.sdkInitialize(getApplicationContext());
}
我还正确配置了清单,如文档所示:

视图中的按钮如下所示:

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


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

请参阅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);
}
注:


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

请参阅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);
}
注:


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

请参阅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);
}
注:


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

我没有将内容设置为共享。这就解决了问题;)这是可行的,但如果我想共享照片,按钮仍然不可用。我没有设置要共享的内容。这就解决了问题;)这是可行的,但如果我想共享照片,按钮仍然不可用。我没有设置要共享的内容。这就解决了问题;)这是可行的,但如果我想共享照片,按钮仍然不可用。我没有设置要共享的内容。这就解决了问题;)这是可行的,但如果我想共享照片,按钮仍然处于禁用状态