How to add title and content after Facebook deprecation?

4u53r :

Here's some code that successfully shares a link to Facebook after a button click:

public void onClick(View view) {
            if (ShareDialog.canShow(ShareLinkContent.class)) {
                ShareLinkContent linkContent = new ShareLinkContent.Builder()
                        .setContentTitle("A title")
                        .setContentDescription("Some description.")
                        .setContentUrl(Uri.parse("www.website.com"))
                        .build();
                shareDialog.show(linkContent);
            }
        }

Using Android Studio, the ".setContentTitle" and ".setContentDescription" are deprecated, with a line through them. When I post the link, it is shared without the title and description. I assume this is because they are deprecated.

How could I add a title and description in? What were the deprecated terms replaced with? This isn't pre-filling a a post, and it wouldn't make sense for Facebook to get rid of these features completely. I have tried a few different links as the URL, none made a difference to this issue.

Many thanks in advance.

Edit: Please note that meta tags aren't an option, because if I were to link to an app in the Google Play Store, I can't control what tags the page has. I am looking to provide a title/description from the app, as was previously possible using the deprecated features mentioned.

4u53r :

I have found a suitable way around this, though not one that specifically replaces title and description. Another way to automatically add text to a post without pre-filling the user's text box is to use .setQuote().

For example with the code I provided above:

public void onClick(View view) {
        if (ShareDialog.canShow(ShareLinkContent.class)) {
            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setQuote("This may be used to replace setTitle and setDescription.")
                    .setContentUrl(Uri.parse("www.website.com"))
                    .build();
            shareDialog.show(linkContent);
        }
    }

If anyone knows a way to replace the deprecated functions properly, without such a different alternative like the one I just provided, please post it and I'll mark it as solved.

Many thanks.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=463222&siteId=1
Recommended