How do I add title and content after Facebook expires?

Here is the code that successfully passes the link to Facebook after clicking the button:

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, ".setContentTitle" and ".setContentDescription" are deprecated, with a line through them. When I post a link, it is shared without a title or description. I assume this is because they are deprecated.

How can I add a title and description? What were the obsolete terms? This is not pre-filling the post, and it wouldn't make sense for Facebook to ditch these features entirely. I tried several different links as url, none of them had anything to do with this problem.

Thank you very much in advance.

Edit: Please note that meta tags are not parameters, because if I need to connect to an app in the Google Play Store, I have no control over which tags have on the page. I want to provide title / description from the app as previously possible using the deprecated features mentioned.

+3


source to share


2 answers


I found a suitable way, although not one that specifically replaces the title and description. Another way to automatically add text to a message without pre-filling the user's text field is to use .setQuote()

.

For example with the above code:

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 of a way to properly replace deprecated features, without such other alternative like the one I just presented, please post it and I will mark it as solved.

Many thanks.

+4


source


You can use ShareOpenGraphContent which uses ShareOpenGraphAction and ShareOpenGraphObject.

Take a look at the code I answered in this question.

fooobar.com/questions/2418281 / ...



This way, you can add a title, description, and even an image to your post.

It works for ShareDialog.show () but unfortunately in my experience it doesn't work for MessageDialog.show ()

0


source







All Articles