适用于Android的Facebook的ShareLinkContent已弃用功能的替代解决方案是什么?

时间:2018-03-19 12:23:58

标签: java android facebook facebook-graph-api

在以前的Facebook API for Android中,我们能够像这样分享带有标题,Imageurl,链接和contentDescription的网址内容

ShareLinkContent content = new ShareLinkContent.Builder()
    .setContentTitle("Planning a trip to Dubai?")
    .setContentDescription("Make sure you visit unique attractions recommended by the local people!")
    .setContentUrl(Uri.parse("https://justa128.github.io/dubai-tour-guide/landingpage/"))
    .setImageUrl(Uri.parse("https://cdn-images-1.medium.com/fit/t/800/240/1*jZ3a6rYqrslI83KJFhdvFg.jpeg"))
    .build();

但是现在不推荐使用方法setContentTitlesetContentDescriptionsetImageUrl。是否有任何替代解决方案与url,imageurl,标题和描述共享内容?

ShareLinkContentFacebook's文档无效。

任何帮助将不胜感激!谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用ShareContent.Builder的setQuote("任何描述字符串")方法来设置要为您的链接显示的引号。 像这样的东西

if (shareDialog.canShow(ShareLinkContent.class)) {

    ShareLinkContent linkContent = new ShareLinkContent.Builder()
           .setQuote("Planning a trip to Dubai? \n Make sure you visit unique attractions recommended by the local people!")
           .setContentUrl(Uri.parse("https://justa128.github.io/dubai-tour guide/landingpage/"))
           .build();

    shareDialog.show(linkContent);
}

P.S .-> setTitle,setDescription和setImageUrl方法现在已在最新的FacebookSDK中弃用,因此我们可以使用setQuote作为标题和详细描述,使用setContentUrl作为链接。