在安卓设备中,Facebook对话框无法弹出。

4

我正在开发一款Android应用程序,使用Facebook SDK for Android。

我想使用Facebook共享对话框:

ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse("https://developers.facebook.com"))
                .build();

当我运行应用程序时,没有任何反应,没有对话框出现 - 也没有错误提示。请问有人可以提供帮助吗?
1个回答

5

首先进行初始化

FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);

Than Show

if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
        .setContentTitle("Hello Facebook")
        .setContentDescription(
                "The 'Hello Facebook' sample  showcases simple Facebook integration")
        .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
        .build();

shareDialog.show(linkContent);
}

最后调用这个函数。

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}

如何仅发布标题、描述和图片,而不包含任何“内容URL”? - Satyam

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接