gpt4 book ai didi

android - Facebook 分享对话框未打开

转载 作者:太空宇宙 更新时间:2023-11-03 10:44:07 25 4
gpt4 key购买 nike

根据这个link here ,我已经安装了 SDK 3.2.1 并实现了一个 uiHelper,以及像这样的 FacebookDialog:

if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
// Publish the post using the Share Dialog
Toast.makeText(this, "if", Toast.LENGTH_LONG).show();
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(
this).setLink("https://developers.facebook.com/android")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());

} else {
Toast.makeText(this, "else", Toast.LENGTH_LONG).show();
// Fallback. For example, publish the post using the Feed Dialog
publishFeedDialog();
}

对于 publishFeedDialog() 我有:

    private void publishFeedDialog() {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption",
"Build great social apps and get more installs.");
params.putString(
"description",
"The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture",
"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this,
Session.getActiveSession(), params)).setOnCompleteListener(
new OnCompleteListener() {

@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(getApplicationContext(),
"Posted story, id: " + postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
} else {
// Generic, ex: network error
Toast.makeText(getApplicationContext(),
"Error posting story", Toast.LENGTH_SHORT)
.show();
}
}

}).build();
feedDialog.show();
}

现在 FacebookDialog.canPresentShareDialog 始终为 false,即使在手机中安装了 Facebook 应用程序然后调用 publishFeedDialog() 也是如此。但是应用程序在此之后崩溃了。

解决这个问题的方法是什么?当应用程序在我的手机中时,为什么会显示正常的 facebook 对话框? (如果有帮助,我正在使用 Lenevo 模型)

最佳答案

您需要更新的 FB 应用程序才能使用共享对话框。确保下载最新的!

此外,不,您不需要登录即可启用共享对话框。

关于android - Facebook 分享对话框未打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27816667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com