Android Facebook分享,描述未显示

时间:2016-03-07 07:24:30

标签: android facebook sdk share

我正在使用facebook sdk在Facebook上分享。 我的代码如下,它工作正常。但是当我想将内容网址更改为应用程序Playstore链接时,内容描述不会显示在Facebook中。 有没有解决方案,或者我犯了愚蠢的错误?

if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle(AppConstant.RESTURENT_NAME)
                .setContentDescription("Hi,You should check out Bangkok Eatery.")
                .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                                .build();

        shareDialog.show(linkContent);
    }

2 个答案:

答案 0 :(得分:0)

 ShareDialog shareDialog = new ShareDialog(this);
    CallbackManager callbackManager = CallbackManager.Factory.create();
    shareDialog.registerCallback(callbackManager, new
            FacebookCallback<Sharer.Result>() {
                @Override
                public void onSuccess(Sharer.Result result) {

                }

                @Override
                public void onCancel() {
                }

                @Override
                public void onError(FacebookException error) {
                }
            });
    ShareLinkContent linkContent = new ShareLinkContent.Builder()
            .setContentTitle(getString(R.string.app_name))
            .setContentDescription("")
            .setContentUrl(Uri.parse("your link"))
            .build();
    shareDialog.show(linkContent);

答案 1 :(得分:0)

FacebookSdk在onCreate方法中初始化

CallbackManager callbackManager;
ShareDialog shareDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);
    // this part is optional
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { ... });
}






if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
            .setContentTitle(AppConstant.RESTURENT_NAME)
            .setContentDescription("Hi,You should check out Bangkok Eatery.")
               .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                            .build();

    shareDialog.show(linkContent);
    }