2
votes

I want to share my apps playstore link with facebook from my app. I am using share dialog to share the link using the below code.

if (ShareDialog.canShow(ShareLinkContent.class)) {
            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.deadbrains.knowledgeup"))
                    .build();
            shareDialog.show(linkContent);
        } else {
            Toast.makeText(SlidingDrawerActivity.this, "Unable to Share...Try again.", Toast.LENGTH_SHORT).show();
        }

when I check with object debugger from here and add the following link https://play.google.com/store/apps/details?id=com.deadbrains.knowledgeup it shows the intended view which I want to share. see the image below enter image description here

but when I run the app and share it from there it looks like below enter image description here

What am I doing wrong? how can I correct this?

2
Facebook is notorious for not necessarily picking the correct image when something is shared--I've had issues with the same in the past. I wouldn't trust their debugger.wblaschko
@wblaschko what can be workaround for this?karan
You could try to use ShareLinkContent.Builder.setImageUrl(Uri uri) to set the image you intend to share, if you know the URL.wblaschko
@wblaschko it did the trick. please post the answer so i can mark itkaran
Done. Glad I could help :)wblaschko

2 Answers

0
votes

As discussed in the comments.

You can use ShareLinkContent.Builder.setImageUrl(Uri uri) to set the image you intend to share, if you know the URL.

0
votes

Try adding imageUri to shareDialog :

if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.deadbrains.knowledgeup"))
                .setImageUrl(Uri.parse("https://lh3.googleusercontent.com/MTN4hDTF3ep5_FumvNIFdfQIQwP7wq9pdsN_zIMALu3nCz7tAJ3MdAdRYeGg3i_wrtl7=w300"))
                .build();
        shareDialog.show(linkContent);
    } else {
        Toast.makeText(SlidingDrawerActivity.this, "Unable to Share...Try again.", Toast.LENGTH_SHORT).show();
    }