我试图在我的应用程序中使用共享按钮,但它看起来好像被禁用了:
我已经初始化了sdk:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
}
我还按照文档的建议正确配置了清单:https://developers.facebook.com/docs/android/getting-started 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);
}
Note:
https://developers.facebook.com/docs/sharing/android https://developers.facebook.com/docs/sharing/android
“当您实现共享时,您的应用程序不应预先填充任何要共享的内容。这与 Facebook 平台政策不一致,请参阅 Facebook 平台政策 2.3。”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)