android 中的 Facebook 对话未出现

Facebook Dialog in android Not coming up

我正在开发 android 应用程序,我在其中使用 Facebook SDK android。

我想使用 Facebook 分享对话框:

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

当我 运行 应用程序没有任何反应,没有出现对话框 - 没有错误。

有人可以帮忙吗?

先初始化

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

比显示

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